mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Update native histogram hints in prometheus data source (#96270)
* [Prometheus] Update native histogram hints * update unit tests
This commit is contained in:
parent
11f1a6b034
commit
4e3e50bf91
@ -216,13 +216,11 @@ describe('getQueryHints()', () => {
|
|||||||
const datasource = mock as PrometheusDatasource;
|
const datasource = mock as PrometheusDatasource;
|
||||||
|
|
||||||
let hints = getQueryHints('foo', series, datasource);
|
let hints = getQueryHints('foo', series, datasource);
|
||||||
expect(hints!.length).toBe(6);
|
expect(hints!.length).toBe(3);
|
||||||
const hintsString = JSON.stringify(hints);
|
const hintsString = JSON.stringify(hints);
|
||||||
expect(hintsString).toContain('ADD_HISTOGRAM_AVG');
|
expect(hintsString).toContain('ADD_HISTOGRAM_AVG');
|
||||||
expect(hintsString).toContain('ADD_HISTOGRAM_COUNT');
|
expect(hintsString).toContain('ADD_HISTOGRAM_COUNT');
|
||||||
expect(hintsString).toContain('ADD_HISTOGRAM_SUM');
|
expect(hintsString).toContain('ADD_HISTOGRAM_QUANTILE');
|
||||||
expect(hintsString).toContain('ADD_HISTOGRAM_FRACTION');
|
|
||||||
expect(hintsString).toContain('ADD_HISTOGRAM_AVG');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns no hints for native histogram when there are native histogram functions in the query', () => {
|
it('returns no hints for native histogram when there are native histogram functions in the query', () => {
|
||||||
|
@ -50,9 +50,20 @@ export function getQueryHints(query: string, series?: unknown[], datasource?: Pr
|
|||||||
|
|
||||||
if (nativeHistogramNameMetric) {
|
if (nativeHistogramNameMetric) {
|
||||||
// add hints:
|
// add hints:
|
||||||
// histogram_avg, histogram_count, histogram_sum, histogram_fraction, histogram_stddev, histogram_stdvar
|
// histogram_quantile, histogram_avg, histogram_count
|
||||||
const label = 'Selected metric is a native histogram.';
|
const label = 'Selected metric is a native histogram.';
|
||||||
hints.push(
|
hints.push(
|
||||||
|
{
|
||||||
|
type: 'HISTOGRAM_QUANTILE',
|
||||||
|
label,
|
||||||
|
fix: {
|
||||||
|
label: 'Consider calculating aggregated quantile by adding histogram_quantile().',
|
||||||
|
action: {
|
||||||
|
type: 'ADD_HISTOGRAM_QUANTILE',
|
||||||
|
query,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type: 'HISTOGRAM_AVG',
|
type: 'HISTOGRAM_AVG',
|
||||||
label,
|
label,
|
||||||
@ -74,52 +85,6 @@ export function getQueryHints(query: string, series?: unknown[], datasource?: Pr
|
|||||||
query,
|
query,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'HISTOGRAM_SUM',
|
|
||||||
label,
|
|
||||||
fix: {
|
|
||||||
label: 'Consider calculating the sum of observations by adding histogram_sum().',
|
|
||||||
action: {
|
|
||||||
type: 'ADD_HISTOGRAM_SUM',
|
|
||||||
query,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'HISTOGRAM_FRACTION',
|
|
||||||
label,
|
|
||||||
fix: {
|
|
||||||
label:
|
|
||||||
'Consider calculating the estimated fraction of observations between the provided lower and upper values by adding histogram_fraction().',
|
|
||||||
action: {
|
|
||||||
type: 'ADD_HISTOGRAM_FRACTION',
|
|
||||||
query,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'HISTOGRAM_STDDEV',
|
|
||||||
label,
|
|
||||||
fix: {
|
|
||||||
label:
|
|
||||||
'Consider calculating the estimated standard deviation of observations by adding histogram_stddev().',
|
|
||||||
action: {
|
|
||||||
type: 'ADD_HISTOGRAM_STDDEV',
|
|
||||||
query,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
type: 'HISTOGRAM_STDVAR',
|
|
||||||
label,
|
|
||||||
fix: {
|
|
||||||
label: 'Consider calculating the estimated standard variance of observations by adding histogram_stdvar().',
|
|
||||||
action: {
|
|
||||||
type: 'ADD_HISTOGRAM_STDVAR',
|
|
||||||
query,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user