mirror of
https://github.com/grafana/grafana.git
synced 2025-08-26 18:40:14 +08:00

* wip: add slo support * Export DataSourcePlugin * wip: break out metric query editor into its own component * wip: refactor frontend - keep SLO and Metric query in differnt objects * wip - load services and slos * Fix broken test * Add interactive slo expression builder * Change order of dropdowns * Refactoring backend model. slo unit testing in progress * Unit test migration and SLOs * Cleanup SLO editor * Simplify alias by component * Support alias by for slos * Support slos in variable queries * Fix broken last query error * Update Help section to include SLO aliases * streamline datasource resource cache * Break out api specific stuff in datasource to its own file * Move get projects call to frontend * Refactor api caching * Unit test api service * Fix lint go issue * Fix typescript strict errors * Fix test datasource * Use budget fraction selector instead of budget * Reset SLO when service is changed * Handle error in case resource call returned no data * Show real SLI display name * Use unsafe prefix on will mount hook * Store goal in query model since it will be used as soon as graph panel supports adding a threshold * Add comment to describe why componentWillMount is used * Interpolate sloid * Break out SLO aggregation into its own func * Also test group bys for metricquery test * Remove not used type fields * Remove annoying stackdriver prefix from error message * Default view param to FULL * Add part about SLO query builder in docs * Use new images * Fixes after feedback * Add one more group by test * Make stackdriver types internal * Update docs/sources/features/datasources/stackdriver.md Co-Authored-By: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/features/datasources/stackdriver.md Co-Authored-By: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/features/datasources/stackdriver.md Co-Authored-By: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Updates after PR feedback * add test for when no alias by defined * fix infinite loop when newVariables feature flag is on onChange being called in componentDidUpdate produces an infinite loop when using the new React template variable implementation. Also fixes a spelling mistake * implements feedback for documentation changes * more doc changes Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> Co-authored-by: Daniel Lee <dan.limerick@gmail.com>
134 lines
4.8 KiB
TypeScript
134 lines
4.8 KiB
TypeScript
import React from 'react';
|
|
import { MetricDescriptor } from '../types';
|
|
|
|
export interface Props {
|
|
rawQuery: string;
|
|
lastQueryError: string;
|
|
metricDescriptor?: MetricDescriptor;
|
|
}
|
|
|
|
interface State {
|
|
displayHelp: boolean;
|
|
displaRawQuery: boolean;
|
|
}
|
|
|
|
export class Help extends React.Component<Props, State> {
|
|
state: State = {
|
|
displayHelp: false,
|
|
displaRawQuery: false,
|
|
};
|
|
|
|
onHelpClicked = () => {
|
|
this.setState({ displayHelp: !this.state.displayHelp });
|
|
};
|
|
|
|
onRawQueryClicked = () => {
|
|
this.setState({ displaRawQuery: !this.state.displaRawQuery });
|
|
};
|
|
|
|
shouldComponentUpdate(nextProps: Props) {
|
|
return nextProps.metricDescriptor !== null;
|
|
}
|
|
|
|
render() {
|
|
const { displayHelp, displaRawQuery } = this.state;
|
|
const { rawQuery, lastQueryError } = this.props;
|
|
|
|
return (
|
|
<>
|
|
<div className="gf-form-inline">
|
|
<div className="gf-form" onClick={this.onHelpClicked}>
|
|
<label className="gf-form-label query-keyword pointer">
|
|
Show Help <i className={`fa fa-caret-${displayHelp ? 'down' : 'right'}`} />
|
|
</label>
|
|
</div>
|
|
|
|
{rawQuery && (
|
|
<div className="gf-form" onClick={this.onRawQueryClicked}>
|
|
<label className="gf-form-label query-keyword">
|
|
Raw Query <i className={`fa fa-caret-${displaRawQuery ? 'down' : 'right'}`} ng-show="ctrl.showHelp" />
|
|
</label>
|
|
</div>
|
|
)}
|
|
|
|
<div className="gf-form gf-form--grow">
|
|
<div className="gf-form-label gf-form-label--grow" />
|
|
</div>
|
|
</div>
|
|
{rawQuery && displaRawQuery && (
|
|
<div className="gf-form">
|
|
<pre className="gf-form-pre">{rawQuery}</pre>
|
|
</div>
|
|
)}
|
|
|
|
{displayHelp && (
|
|
<div className="gf-form grafana-info-box alert-info">
|
|
<div>
|
|
<h5>Alias Patterns</h5>Format the legend keys any way you want by using alias patterns. Format the legend
|
|
keys any way you want by using alias patterns.
|
|
<br /> <br />
|
|
Example:
|
|
<code>{`${'{{metricDescriptor.name}} - {{metricDescriptor.label.instance_name}}'}`}</code>
|
|
<br />
|
|
Result: <code>cpu/usage_time - server1-europe-west-1</code>
|
|
<br />
|
|
<br />
|
|
<strong>Patterns</strong>
|
|
<br />
|
|
<ul>
|
|
<li>
|
|
<code>{`${'{{metricDescriptor.type}}'}`}</code> = metric type e.g.
|
|
compute.googleapis.com/instance/cpu/usage_time
|
|
</li>
|
|
<li>
|
|
<code>{`${'{{metricDescriptor.name}}'}`}</code> = name part of metric e.g. instance/cpu/usage_time
|
|
</li>
|
|
<li>
|
|
<code>{`${'{{metricDescriptor.service}}'}`}</code> = service part of metric e.g. compute
|
|
</li>
|
|
<li>
|
|
<code>{`${'{{metricDescriptor.label.label_name}}'}`}</code> = Metric label metadata e.g.
|
|
metricDescriptor.label.instance_name
|
|
</li>
|
|
<li>
|
|
<code>{`${'{{resource.label.label_name}}'}`}</code> = Resource label metadata e.g. resource.label.zone
|
|
</li>
|
|
<li>
|
|
<code>{`${'{{metadata.system_labels.name}}'}`}</code> = Meta data system labels e.g.
|
|
metadata.system_labels.name. For this to work, the needs to be included in the group by
|
|
</li>
|
|
<li>
|
|
<code>{`${'{{metadata.user_labels.name}}'}`}</code> = Meta data user labels e.g.
|
|
metadata.user_labels.name. For this to work, the needs to be included in the group by
|
|
</li>
|
|
<li>
|
|
<code>{`${'{{bucket}}'}`}</code> = bucket boundary for distribution metrics when using a heatmap in
|
|
Grafana
|
|
</li>
|
|
<li>
|
|
<code>{`${'{{project}}'}`}</code> = The project name that was specified in the query editor
|
|
</li>
|
|
<li>
|
|
<code>{`${'{{service}}'}`}</code> = The service id that was specified in the SLO query editor
|
|
</li>
|
|
<li>
|
|
<code>{`${'{{slo}}'}`}</code> = The SLO id that was specified in the SLO query editor
|
|
</li>
|
|
<li>
|
|
<code>{`${'{{selector}}'}`}</code> = The Selector function that was specified in the SLO query editor
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{lastQueryError && (
|
|
<div className="gf-form">
|
|
<pre className="gf-form-pre alert alert-error">{lastQueryError}</pre>
|
|
</div>
|
|
)}
|
|
</>
|
|
);
|
|
}
|
|
}
|