Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alerting: create LabelPicker component for Prometheus / Cortex / Loki labels #45455

Closed
5 tasks
Tracked by #51425
gillesdemey opened this issue Feb 16, 2022 · 2 comments · Fixed by #57783
Closed
5 tasks
Tracked by #51425

Alerting: create LabelPicker component for Prometheus / Cortex / Loki labels #45455

gillesdemey opened this issue Feb 16, 2022 · 2 comments · Fixed by #57783
Assignees
Labels

Comments

@gillesdemey
Copy link
Member

gillesdemey commented Feb 16, 2022

We have a few different places where we could improve the alerting UI by allowing the user to select existing label keys / values.

The Prometheus and Loki datasources expose the necessary functions for querying label keys and values.

  • Create LabelKeyPicker and LabelValuePicker components
  • Implement in create rule / edit rule

Image

(stretch/do later)

  • Implement in notification policies
  • Implement in silences
  • Implement in Alert Panel

For Prometheus / Cortex

async getTagKeys(options?: any) {
if (options?.series) {
// Get tags for the provided series only
const seriesLabels: Array<Record<string, string[]>> = await Promise.all(
options.series.map((series: string) => this.languageProvider.fetchSeriesLabels(series))
);
const uniqueLabels = [...new Set(...seriesLabels.map((value) => Object.keys(value)))];
return uniqueLabels.map((value: any) => ({ text: value }));
} else {
// Get all tags
const result = await this.metadataRequest('/api/v1/labels');
return result?.data?.data?.map((value: any) => ({ text: value })) ?? [];
}
}

For Loki

async labelNamesQuery() {
const url = `${LOKI_ENDPOINT}/label`;
const params = this.getTimeRangeParams();
const result = await this.metadataRequest(url, params);
return result.map((value: string) => ({ text: value }));
}

@grafanabot
Copy link
Contributor

This issue was removed from the 8.5.0 milestone because 8.5.0 is currently being released.

@konrad147 konrad147 self-assigned this Jun 15, 2022
@konrad147 konrad147 added this to the 9.1.0 milestone Jun 22, 2022
@armandgrillet armandgrillet added area/alerting Grafana Alerting and removed area/alerting/unified labels Jun 22, 2022
@malcolmholmes malcolmholmes modified the milestones: 9.1.0-beta1, 9.1.0 Aug 2, 2022
@konrad147 konrad147 removed their assignment Aug 9, 2022
@grafanabot grafanabot removed this from the 9.1.0 milestone Aug 16, 2022
@grafanabot
Copy link
Contributor

This issue was removed from the 9.1.0 milestone because 9.1.0 is currently being released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants