From 33b48f7c6effc738efd98e28da0a7e3a4d69c835 Mon Sep 17 00:00:00 2001 From: Adela Almasan <88068998+adela-almasan@users.noreply.github.com> Date: Wed, 12 Feb 2025 04:46:00 -0600 Subject: [PATCH 1/2] PanelPlugin: Allow inverting `hideFromDefaults` (#100473) --- .../src/panel/registryFactories.ts | 2 +- .../PanelEditor/OptionsPaneOptions.test.tsx | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/grafana-data/src/panel/registryFactories.ts b/packages/grafana-data/src/panel/registryFactories.ts index a312d0c128e..98d8acb660d 100644 --- a/packages/grafana-data/src/panel/registryFactories.ts +++ b/packages/grafana-data/src/panel/registryFactories.ts @@ -55,7 +55,7 @@ export function createFieldConfigRegistry( const customDefault = config.standardOptions[id]?.defaultValue; const customSettings = config.standardOptions[id]?.settings; - if (customHideFromDefaults) { + if (customHideFromDefaults !== undefined) { fieldConfigProp = { ...fieldConfigProp, hideFromDefaults: customHideFromDefaults, diff --git a/public/app/features/dashboard/components/PanelEditor/OptionsPaneOptions.test.tsx b/public/app/features/dashboard/components/PanelEditor/OptionsPaneOptions.test.tsx index ad8c19ee30b..6387aac97a8 100644 --- a/public/app/features/dashboard/components/PanelEditor/OptionsPaneOptions.test.tsx +++ b/public/app/features/dashboard/components/PanelEditor/OptionsPaneOptions.test.tsx @@ -143,6 +143,29 @@ describe('OptionsPaneOptions', () => { expect(screen.queryByLabelText(OptionsPaneSelector.fieldLabel('TestPanel HiddenFromDef'))).not.toBeInTheDocument(); }); + it('should render options that are specifically not marked as hidden from defaults', () => { + const scenario = new OptionsPaneOptionsTestScenario(); + + scenario.plugin = getPanelPlugin({ + id: 'TestPanel', + }).useFieldConfig({ + standardOptions: {}, + useCustomConfig: (b) => { + b.addBooleanSwitch({ + name: 'CustomBool', + path: 'CustomBool', + }).addBooleanSwitch({ + name: 'HiddenFromDef', + path: 'HiddenFromDef', + hideFromDefaults: false, + }); + }, + }); + + scenario.render(); + expect(screen.queryByLabelText(OptionsPaneSelector.fieldLabel('TestPanel HiddenFromDef'))).toBeInTheDocument(); + }); + it('should create categories for field options with category', () => { const scenario = new OptionsPaneOptionsTestScenario(); scenario.render(); From 2f329c211d56c919ae671841ac6dfd8c4245cf94 Mon Sep 17 00:00:00 2001 From: antonio <45235678+tonypowa@users.noreply.github.com> Date: Wed, 12 Feb 2025 12:01:15 +0100 Subject: [PATCH 2/2] docs>tutorials>minor-update (#100488) * docs>tutorials>minor-update * link to part 5 from part 4 * all pretty, no pity --- .../alerting-get-started-pt4/index.md | 18 ++++++++++++++++++ .../alerting-get-started-pt5/index.md | 18 +++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/docs/sources/tutorials/alerting-get-started-pt4/index.md b/docs/sources/tutorials/alerting-get-started-pt4/index.md index 4ea4477e655..1b480d375b8 100644 --- a/docs/sources/tutorials/alerting-get-started-pt4/index.md +++ b/docs/sources/tutorials/alerting-get-started-pt4/index.md @@ -420,4 +420,22 @@ To deepen your understanding of Grafana’s templating, explore the following re - [**Notification template reference**](https://grafana.com/docs/grafana/latest/alerting/configure-notifications/template-notifications/reference/): Lists the data available for use in notification templates and explores specific functions. - [**Alert rule template reference**](https://grafana.com/docs/grafana/latest/alerting/alerting-rules/templates/reference/): Covers the specifics of creating dynamic labels and annotations for alert rules using elements such as variables and functions. +## Learn more in [Grafana Alerting Part 5](http://www.grafana.com/tutorials/alerting-get-started-pt5/) + + + +{{< admonition type="tip" >}} + +In [Get started with Grafana Alerting - Part 5](http://www.grafana.com/tutorials/alerting-get-started-pt5/) you learn how to dynamically route alerts and link them to dashboards. + +{{< /admonition >}} + + + +{{< docs/ignore >}} + +In [Get started with Grafana Alerting - Part 5](http://www.grafana.com/tutorials/alerting-get-started-pt5/) you learn how to dynamically route alerts and link them to dashboards. + +{{< /docs/ignore >}} + diff --git a/docs/sources/tutorials/alerting-get-started-pt5/index.md b/docs/sources/tutorials/alerting-get-started-pt5/index.md index e4e08b82d1a..e2049b494ca 100644 --- a/docs/sources/tutorials/alerting-get-started-pt5/index.md +++ b/docs/sources/tutorials/alerting-get-started-pt5/index.md @@ -2,7 +2,7 @@ Feedback Link: https://github.com/grafana/tutorials/issues/new categories: - alerting -description: Learn how to dinamically route alerts and link them to dashboards — Part 5. +description: Learn how to dynamically route alerts and link them to dashboards — Part 5. labels: products: - enterprise @@ -14,7 +14,7 @@ title: Get started with Grafana Alerting - Part 5 weight: 60 killercoda: title: Get started with Grafana Alerting - Part 5 - description: Learn how to dinamically route alerts and link them to dashboards — Part 5. + description: Learn how to dynamically route alerts and link them to dashboards — Part 5. backend: imageid: ubuntu --- @@ -30,7 +30,7 @@ In this tutorial, we focus on optimizing your alerting strategy using Grafana fo In this tutorial you will learn how to: - Leverage notification policies for **dynamic routing based on query values**: Use notification policies to route alerts based on dynamically generated labels, in a way that critical alerts reach the on-call team and less urgent ones go to a general monitoring channel. -- Set **mute timings** to suppress certain alerts during maintenance, or weekends. +- Set **mute timings** to suppress certain alerts during maintenance or weekends. - **Link alerts to dashboards** to provide more context to resolve issues. @@ -53,7 +53,7 @@ In this tutorial you will learn how to: ### Set up the Grafana stack -To demonstrate the observation of data using the Grafana stack, download and run the following files. +To observe data using the Grafana stack, download and run the following files. 1. Clone the [tutorial environment repository](https://github.com/tonypowa/grafana-prometheus-alerting-demo.git). @@ -199,9 +199,9 @@ The time-series visualization supports alert rules to provide more context in th flask_app_memory_usage{environment="prod"} ``` - {{< figure src="/media/docs/alerting/time-series_cpu_mem_usage_metrics.png" max-width="1200px" caption="Time-series panel displaying CPU and memory usage metrics in production." >}} + {{< figure src="/media/docs/alerting/time-series_cpu_mem_usage_metrics.png" max-width="1200px" caption="Time-series panel displaying CPU and memory usage metrics in production." >}} - Both metrics return labels that we’ll use later to link alert instances with the appropriate routing. These labels help define how alerts are routed based on their environment or other criteria. + Both metrics return labels that we’ll use later to link alert instances with the appropriate routing. These labels help define how alerts are routed based on their environment or other criteria. 1. Click **Save dashboard**. @@ -252,11 +252,11 @@ Follow these steps to manually create alert rules and link them to a visualizati ## Create an alert rule for CPU usage 1. Navigate to **Alerts & IRM > Alerting > Alert rules** from the Grafana sidebar. -1. Click **+ New alert** rule to create a new alert. +1. Click **+ New alert rule** rule to create a new alert. ### Enter alert rule name -Make it short and descriptive as this will appear in your alert notification. For instance, `CPU usage` . +Make it short and descriptive, as this will appear in your alert notification. For instance, `CPU usage` . ### Define query and alert condition @@ -354,7 +354,7 @@ Now that we've set up notification policies, we can demonstrate how to mute aler Mute timings are useful for suppressing alerts with certain labels during maintenance windows or weekends. 1. Navigate to **Alerts & IRM > Alerting > Notification Policies**. - - Enter a name. E.g., `Planned downtime` , or `Non-business hours`. + - Enter a name, e.g. `Planned downtime` or `Non-business hours`. - Select **Sat** and **Sun**, to apply the mute timing to all Saturdays and Sundays. - Click **Save mute timing**. 1. Add mute timing to the desired policy: