Closed matthewmgamble closed 3 years ago
findInLabelMap
is kind of a hook, called for each series. It takes a single argument (a metric object) and returns a string.
I'm not sure about the content of this object. Can you please provide an example in a comment? The doc needs to be improved. ;)
You can use it in this way:
var myChart = new Chart(ctx, {
type: 'line',
plugins: [ChartDatasourcePrometheusPlugin],
options: {
plugins: {
'datasource-prometheus': {
prometheus: {
endpoint: "http://demo.robustperception.io:9090",
baseURL: "/api/v1", // default value
},
query: 'sum by (job) (go_gc_duration_seconds)',
findInLabelMap: (metric) => {
console.log(metric);
return 'hello world';
},
timeRange: {
type: 'relative',
// from 12 hours ago to now
start: -12 * 60 * 60 * 1000,
end: 0,
},
},
},
},
});
Added to documentation
I can't find any examples of how to use findInLabelMap to change the series labels in the final chart - are there any examples of how to use this to customize labels?