Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions workspaces/grafana/.changeset/empty-oranges-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage-community/plugin-grafana': minor
---

All existing deprecated references have been removed. If you were still using the `GRAFANA_ANNOTATION_TAG_SELECTOR` annotation, it is now required you replace it with the `GRAFANA_ANNOTATION_DASHBOARD_SELECTOR` annotation.
3 changes: 2 additions & 1 deletion workspaces/grafana/bcp.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"autoVersionBump": true,
"knipReports": false
"knipReports": false,
"listDeprecations": true
}
10 changes: 1 addition & 9 deletions workspaces/grafana/plugins/grafana/report.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ export const GRAFANA_ANNOTATION_DASHBOARD_SELECTOR =
export const GRAFANA_ANNOTATION_OVERVIEW_DASHBOARD =
'grafana/overview-dashboard';

// @public @deprecated
export const GRAFANA_ANNOTATION_TAG_SELECTOR = 'grafana/tag-selector';

// @public
export interface GrafanaApi {
alertsForSelector(selectors: string | string[]): Promise<Alert[]>;
Expand All @@ -105,18 +102,13 @@ export const grafanaPlugin: BackstagePlugin<{}, {}, {}>;
export const isAlertSelectorAvailable: (entity: Entity) => boolean;

// @public
export const isDashboardSelectorAvailable: (
entity: Entity,
) => string | undefined;
export const isDashboardSelectorAvailable: (entity: Entity) => string;

// @public
export const isOverviewDashboardAvailable: (entity: Entity) => boolean;

// @public
export const overviewDashboardFromEntity: (entity: Entity) => string;

// @public @deprecated
export const tagSelectorFromEntity: (entity: Entity) => string;

// (No @packageDocumentation comment for this package)
```
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
GRAFANA_ANNOTATION_ALERT_LABEL_SELECTOR,
GRAFANA_ANNOTATION_OVERVIEW_DASHBOARD,
GRAFANA_ANNOTATION_DASHBOARD_SELECTOR,
GRAFANA_ANNOTATION_TAG_SELECTOR,
} from '../constants';

export const sampleEntity = {
Expand All @@ -28,7 +27,6 @@ export const sampleEntity = {
name: 'awesome-service',
annotations: {
[GRAFANA_ANNOTATION_ALERT_LABEL_SELECTOR]: 'service=awesome-service',
[GRAFANA_ANNOTATION_TAG_SELECTOR]: 'awesome-tag',
[GRAFANA_ANNOTATION_DASHBOARD_SELECTOR]:
"(tags @> 'my-service' || tags @> 'my-service-slo') && tags @> 'generated'",
[GRAFANA_ANNOTATION_OVERVIEW_DASHBOARD]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ import useAsync from 'react-use/lib/useAsync';
import { Alert } from '@material-ui/lab';
import { AlertsCardOpts, Alert as GrafanaAlert } from '../../types';
import {
GRAFANA_ANNOTATION_TAG_SELECTOR,
GRAFANA_ANNOTATION_ALERT_LABEL_SELECTOR,
isAlertSelectorAvailable,
isDashboardSelectorAvailable,
tagSelectorFromEntity,
alertSelectorFromEntity,
GRAFANA_ANNOTATION_DASHBOARD_SELECTOR,
dashboardSelectorFromEntity,
} from '../../constants';

const AlertStatusBadge = ({ alert }: { alert: GrafanaAlert }) => {
Expand Down Expand Up @@ -128,7 +128,7 @@ const Alerts = ({ entity, opts }: { entity: Entity; opts: AlertsCardOpts }) => {
configApi.getOptionalBoolean('grafana.unifiedAlerting') || false;
const alertSelector = unifiedAlertingEnabled
? alertSelectorFromEntity(entity)
: tagSelectorFromEntity(entity);
: dashboardSelectorFromEntity(entity);

const { value, loading, error } = useAsync(
async () => await grafanaApi.alertsForSelector(alertSelector),
Expand All @@ -152,7 +152,7 @@ export const AlertsCard = (opts?: AlertsCardOpts) => {
if (!unifiedAlertingEnabled && !isDashboardSelectorAvailable(entity)) {
return (
<MissingAnnotationEmptyState
annotation={GRAFANA_ANNOTATION_TAG_SELECTOR}
annotation={GRAFANA_ANNOTATION_DASHBOARD_SELECTOR}
/>
);
}
Expand Down
21 changes: 2 additions & 19 deletions workspaces/grafana/plugins/grafana/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@

import { Entity } from '@backstage/catalog-model';

/**
* Grafana tag selector annotation
* @public
* @deprecated Use GRAFANA_ANNOTATION_DASHBOARD_SELECTOR instead.
*/
export const GRAFANA_ANNOTATION_TAG_SELECTOR = 'grafana/tag-selector';

/**
* Grafana dashboard selector annotation
* @public
Expand All @@ -49,8 +42,7 @@ export const GRAFANA_ANNOTATION_OVERVIEW_DASHBOARD =
* @public
*/
export const isDashboardSelectorAvailable = (entity: Entity) =>
entity?.metadata.annotations?.[GRAFANA_ANNOTATION_DASHBOARD_SELECTOR] ||
entity?.metadata.annotations?.[GRAFANA_ANNOTATION_TAG_SELECTOR];
entity?.metadata.annotations?.[GRAFANA_ANNOTATION_DASHBOARD_SELECTOR] ?? '';

/**
* Returns if the alert selector annotation for an entity is set
Expand All @@ -75,9 +67,7 @@ export const isOverviewDashboardAvailable = (entity: Entity) =>
* @public
*/
export const dashboardSelectorFromEntity = (entity: Entity) =>
entity?.metadata.annotations?.[GRAFANA_ANNOTATION_DASHBOARD_SELECTOR] ??
entity?.metadata.annotations?.[GRAFANA_ANNOTATION_TAG_SELECTOR] ??
'';
entity?.metadata.annotations?.[GRAFANA_ANNOTATION_DASHBOARD_SELECTOR] ?? '';
/**
* Returns the alert selector annotation for an entity
* @public
Expand All @@ -99,10 +89,3 @@ export const alertSelectorFromEntity = (entity: Entity) => {
*/
export const overviewDashboardFromEntity = (entity: Entity) =>
entity?.metadata.annotations?.[GRAFANA_ANNOTATION_OVERVIEW_DASHBOARD] ?? '';

/**
* Returns the dashboard selector annotation for an entity
* @public
* @deprecated Use dashboardSelectorFromEntity instead
*/
export const tagSelectorFromEntity = dashboardSelectorFromEntity;