mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Small UX updates (#37694)
This commit is contained in:
parent
36c798eb2f
commit
4cf097c4e5
@ -36,7 +36,7 @@ const LOGQL_EXAMPLES = [
|
||||
export default class LokiCheatSheet extends PureComponent<QueryEditorHelpProps<LokiQuery>, { userExamples: string[] }> {
|
||||
declare userLabelTimer: NodeJS.Timeout;
|
||||
state = {
|
||||
userExamples: DEFAULT_EXAMPLES,
|
||||
userExamples: [],
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
@ -81,23 +81,28 @@ export default class LokiCheatSheet extends PureComponent<QueryEditorHelpProps<L
|
||||
|
||||
render() {
|
||||
const { userExamples } = this.state;
|
||||
const hasUserExamples = userExamples.length > 0;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Loki Cheat Sheet</h2>
|
||||
<div className="cheat-sheet-item">
|
||||
<div className="cheat-sheet-item__title">See your logs</div>
|
||||
<div className="cheat-sheet-item__label">Start by selecting a log stream from the Log labels selector.</div>
|
||||
<div className="cheat-sheet-item__label">
|
||||
Alternatively, you can write a stream selector into the query field:
|
||||
Start by selecting a log stream from the Log browser, or alternatively you can write a stream selector into
|
||||
the query field.
|
||||
</div>
|
||||
{this.renderExpression('{job="default/prometheus"}')}
|
||||
{userExamples !== DEFAULT_EXAMPLES && userExamples.length > 0 ? (
|
||||
{hasUserExamples ? (
|
||||
<div>
|
||||
<div className="cheat-sheet-item__label">Here are some example streams from your logs:</div>
|
||||
{userExamples.map((example) => this.renderExpression(example))}
|
||||
</div>
|
||||
) : null}
|
||||
) : (
|
||||
<div>
|
||||
<div className="cheat-sheet-item__label">Here is an example of a log stream:</div>
|
||||
{this.renderExpression(DEFAULT_EXAMPLES[0])}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="cheat-sheet-item">
|
||||
<div className="cheat-sheet-item__title">Combine stream selectors</div>
|
||||
|
@ -424,7 +424,11 @@ export default class LokiLanguageProvider extends LanguageProvider {
|
||||
|
||||
const res = await this.request(url, timeRange);
|
||||
if (Array.isArray(res)) {
|
||||
this.labelKeys = res.slice().sort();
|
||||
const labels = res
|
||||
.slice()
|
||||
.sort()
|
||||
.filter((label) => label !== '__name__');
|
||||
this.labelKeys = labels;
|
||||
}
|
||||
|
||||
return [];
|
||||
|
Loading…
Reference in New Issue
Block a user