The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/trails/AutomaticMetricQueries/units.ts

21 lines
639 B

const DEFAULT_UNIT = 'short';
export function getUnit(metricPart: string | undefined) {
return (metricPart && UNIT_MAP[metricPart]) || DEFAULT_UNIT;
}
const UNIT_MAP: Record<string, string> = {
bytes: 'bytes',
seconds: 's',
};
const RATE_UNIT_MAP: Record<string, string> = {
bytes: 'Bps', // bytes per second
seconds: 'short', // seconds per second is unitless -- this may indicate a count of some resource that is active
};
const DEFAULT_RATE_UNIT = 'cps'; // Count per second
export function getPerSecondRateUnit(metricPart: string | undefined) {
return (metricPart && RATE_UNIT_MAP[metricPart]) || DEFAULT_RATE_UNIT;
}