mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Chore: Enable eslint react/display-name Enable react/display-name and fixed the corresponding linting issue part of: #29201 * Chore: Enable eslint react/no-deprecated Enable react/no-deprecated and add the UNSAFE_ prefix for deprected methods part of: #29201 * Chore: Enable eslint react/no-find-dom-node Enable react/no-find-dom-node rule and use ref instead part of: #29201 * Test: Update TeamGroupSync test snapshot Since we added the displayName for ToolTip compontent and tag name is changed. * Fix: Fixed ClickOutsideWrapper render The props.children might contains numbers of nodes which make cloneElement failed. Change to simply use a div to wrapper the children and assign the ref to div for this feature * Style: Use shorthand method definition style for inline component * Fix: Rebase master and fix linting Rebase from master branch and fix new displayName linting warning
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import React from 'react';
|
|
import { ExploreStartPageProps, DataQuery } from '@grafana/data';
|
|
|
|
const CHEAT_SHEET_ITEMS = [
|
|
{
|
|
title: 'Request Rate',
|
|
expression: 'rate(http_request_total[5m])',
|
|
label:
|
|
'Given an HTTP request counter, this query calculates the per-second average request rate over the last 5 minutes.',
|
|
},
|
|
{
|
|
title: '95th Percentile of Request Latencies',
|
|
expression: 'histogram_quantile(0.95, sum(rate(prometheus_http_request_duration_seconds_bucket[5m])) by (le))',
|
|
label: 'Calculates the 95th percentile of HTTP request rate over 5 minute windows.',
|
|
},
|
|
{
|
|
title: 'Alerts Firing',
|
|
expression: 'sort_desc(sum(sum_over_time(ALERTS{alertstate="firing"}[24h])) by (alertname))',
|
|
label: 'Sums up the alerts that have been firing over the last 24 hours.',
|
|
},
|
|
{
|
|
title: 'Step',
|
|
label:
|
|
'Defines the graph resolution using a duration format (15s, 1m, 3h, ...). Small steps create high-resolution graphs but can be slow over larger time ranges. Using a longer step lowers the resolution and smooths the graph by producing fewer datapoints. If no step is given the resolution is calculated automatically.',
|
|
},
|
|
];
|
|
|
|
const PromCheatSheet = (props: ExploreStartPageProps) => (
|
|
<div>
|
|
<h2>PromQL Cheat Sheet</h2>
|
|
{CHEAT_SHEET_ITEMS.map((item, index) => (
|
|
<div className="cheat-sheet-item" key={index}>
|
|
<div className="cheat-sheet-item__title">{item.title}</div>
|
|
{item.expression ? (
|
|
<div
|
|
className="cheat-sheet-item__example"
|
|
onClick={e => props.onClickExample({ refId: 'A', expr: item.expression } as DataQuery)}
|
|
>
|
|
<code>{item.expression}</code>
|
|
</div>
|
|
) : null}
|
|
<div className="cheat-sheet-item__label">{item.label}</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
);
|
|
|
|
export default PromCheatSheet;
|