Custom MaxDataPoints And IntervalMs Values Are Ignored (defaults Used Instead)
Custom maxDataPoints and intervalMs values are ignored (defaults used instead)
Introduction
When working with custom query runners in Grafana, it's essential to have control over the properties that define the data retrieval process. However, in certain situations, the specified values for maxDataPoints
and intervalMs
are being ignored, and the default values are used instead. This article aims to provide a detailed explanation of this issue, its environment, and potential solutions.
Environment
Initially, this issue was detected in @grafana/scenes
version 3.14.0. Further investigation revealed that the same behavior is reproduced in a new plugin using @grafana/scenes
version 5.42.0. This suggests that the issue is not specific to a particular version but rather a broader problem that affects multiple versions of the @grafana/scenes
package.
Example Query Runner
To better understand the issue, let's take a look at an example query runner:
const query_runner = new SceneQueryRunner({
datasource: PROMETHEUS_DATASOURCE,
queries: [
{
refId: 'A',
expr: `rdb_cpu_cores{instance=\"$instance\", kind=\"logical\"} * 100`,
format: "timeseries",
instant: false,
range: true,
intervalMs: 60000,
maxDataPoints: 600,
}
]
});
In this example, we're creating a new SceneQueryRunner
instance with a custom datasource
and a single query. The query is defined with a specific expr
, format
, and intervalMs
value of 60,000 milliseconds (1 minute). Additionally, we're setting the maxDataPoints
value to 600.
Expected Result
When running this query, we would expect the intervalMs
and maxDataPoints
values to be used as specified. However, the actual result is different.
Actual Result
The actual result, as shown in the browser output, is:
{
"queries": [
{
"refId":"A",
"expr":"rdb_cpu_cores{instance=\"127.0.0.1:3051\", kind=\"logical\"} * 100",
"format":"timeseries",
"instant":false,
"range":true,
"interval":"",
"datasource":
{
"type":"prometheus",
"uid":"cejnygl4duayoc"
},
"exemplar":false,
"requestId": "undefinedA",
"utcOffsetSec":10800,
"scopes":[],
"adhocFilters":[],
"legendFormat":"",
"datasourceId":2,
"intervalMs":30000,
"maxDataPoints":500
}
],"from":"1745291050158","to":"1745312650158"}
As we can see, the intervalMs
value is set to 30,000 milliseconds (0.5 minutes), which is the default value, and the maxDataPoints
value is set to 500, which is also the default value.
Similar Issue
This issue is similar to #647, which suggests that there might be a common root cause or a related problem that needs to be addressed.
Conclusion
In conclusion, the custom maxDataPoints
and intervalMs
values are being ignored, and the default values are used instead. This issue affects multiple versions of the @grafana/scenes
package and is similar to another reported issue. Further investigation and potential solutions are required to resolve this problem.
Potential Solutions
To resolve this issue, we can try the following potential solutions:
- Update to the latest version: Ensure that you're using the latest version of the
@grafana/scenes
package. - Check for conflicts: Verify that there are no conflicts with other packages or dependencies that might be causing this issue.
- Customize the query runner: Try customizing the query runner to use the desired values for
maxDataPoints
andintervalMs
. - Report the issue: If none of the above solutions work, report the issue to the Grafana community or the
@grafana/scenes
package maintainers.
Future Work
To further investigate this issue, we can:
- Analyze the code: Analyze the code of the
@grafana/scenes
package to identify the root cause of the issue. - Test different scenarios: Test different scenarios to reproduce the issue and gather more information.
- Collaborate with the community: Collaborate with the Grafana community and the
@grafana/scenes
package maintainers to resolve this issue.
By following these steps, we can work towards resolving this issue and ensuring that custom maxDataPoints
and intervalMs
values are used as specified in Grafana query runners.
Custom maxDataPoints and intervalMs values are ignored (defaults used instead)
Q&A
Q: What is the issue with custom maxDataPoints and intervalMs values in Grafana query runners?
A: The issue is that the specified values for maxDataPoints
and intervalMs
are being ignored, and the default values are used instead.
Q: Which versions of the @grafana/scenes package are affected by this issue?
A: This issue was initially detected in @grafana/scenes
version 3.14.0 and is also reproduced in a new plugin using @grafana/scenes
version 5.42.0.
Q: What is the expected result when using custom maxDataPoints and intervalMs values in a query runner?
A: The expected result is that the specified values for maxDataPoints
and intervalMs
are used as specified.
Q: What is the actual result when using custom maxDataPoints and intervalMs values in a query runner?
A: The actual result is that the default values for maxDataPoints
and intervalMs
are used instead of the specified values.
Q: Is this issue similar to another reported issue?
A: Yes, this issue is similar to #647, which suggests that there might be a common root cause or a related problem that needs to be addressed.
Q: What are some potential solutions to resolve this issue?
A: Some potential solutions include:
- Update to the latest version: Ensure that you're using the latest version of the
@grafana/scenes
package. - Check for conflicts: Verify that there are no conflicts with other packages or dependencies that might be causing this issue.
- Customize the query runner: Try customizing the query runner to use the desired values for
maxDataPoints
andintervalMs
. - Report the issue: If none of the above solutions work, report the issue to the Grafana community or the
@grafana/scenes
package maintainers.
Q: What are some steps to further investigate this issue?
A: Some steps to further investigate this issue include:
- Analyze the code: Analyze the code of the
@grafana/scenes
package to identify the root cause of the issue. - Test different scenarios: Test different scenarios to reproduce the issue and gather more information.
- Collaborate with the community: Collaborate with the Grafana community and the
@grafana/scenes
package maintainers to resolve this issue.
Q: How can I ensure that custom maxDataPoints and intervalMs values are used as specified in Grafana query runners?
A: To ensure that custom maxDataPoints
and intervalMs
values are used as specified, you can try the following:
- Use the latest version: Ensure that you're using the latest version of the
@grafana/scenes
package. - Customize the query runner: Try customizing the query runner to use the desired values for
maxDataPoints
andintervalMs
. - Report the issue: If none of the above solutions work, report the issue to the Grafana community or the
@grafana/scenes
package maintainers.
By following these steps and potential solutions, you can towards resolving this issue and ensuring that custom maxDataPoints
and intervalMs
values are used as specified in Grafana query runners.