dev_docs/lens/gauge.mdx
import Dataset from './dataset.mdx'; import Breakdown from './breakdown.mdx';
Understanding LensGaugeConfig in detail
chartType'gauge'titlestringvalueLensLayerQuerylabelstringqueryMinValueLensLayerQueryqueryMaxValueLensLayerQueryqueryGoalValueLensLayerQueryshape'arc' | 'circle' | 'horizontalBullet' | 'verticalBullet'const gaugeConfig: LensConfig = {
chartType: 'gauge',
title: 'CPU Utilization',
dataset: {
esql: 'from myindex | stats avgCpuUtilization = avg(cpu_utilization) | eval max=100 ',
},
value: 'avgCpuUtilization',
label: 'Average CPU Utilization',
queryMaxValue: 'max',
shape: 'arc',
};
const configBuilder = new LensConfigBuilder(dataViewsAPI, lensFormulaAPI);
const lensConfig = configBuilder.build(gaugeConfig, {
timeRange: { from: 'now-1h', to: 'now', type: 'relative' },
embeddable: true,
});
This example demonstrates how to create a gauge visualization using the LensGaugeConfig. It sets up a gauge to display the average CPU utilization.