Commit Graph
100 Commits
Author SHA1 Message Date
George Robinson f3e5ad00d6 Remove extra defers in screenshot sevice (#84697) 2024-03-20 07:13:16 +00:00
George Robinson 96127dce62 Alerting: Fix bug in screenshot service using incorrect limit (#83786)
This commit fixes a bug in the screenshot service where
[alerting].concurrent_render_limit was used instead of
[rendering].concurrent_render_request_limit, as in the
docs.
2024-03-01 17:17:55 +00:00
George Robinson a0353b237a Alerting: Update swagger specs (#83260) 2024-02-23 11:25:43 +00:00
George Robinson a564c8c439 Alerting: Keep order of time and mute time intervals consistent (#83257) 2024-02-22 16:57:20 +00:00
George Robinson 1ed1242358 Alerting: Basic support for time_intervals (#83216)
This commit adds basic support for time_intervals, as mute_time_intervals
is deprecated in Alertmanager and scheduled to be removed before 1.0.
It does not add support for time_intervals in API or file provisioning,
nor does it support exporting time intervals. This will be added in
later commits to keep the changes as simple as possible.
2024-02-22 15:58:56 +00:00
George Robinson 556d531c8d Alerting: Update grafana/alerting to 92f64f0 (#82373) 2024-02-13 15:37:33 +02:00
George Robinson 90a26e18db Alerting: Update Alertmanager to e82436c (#82145)
This commit updates Alertmanager to commit e82436c, which is based
on commit f69a508 from Prometheus Alertmanager.
2024-02-08 11:25:27 +00:00
George Robinson c8ccc4649c Alerting: Support UTF-8 (#81512)
This pull request updates our fork of Alertmanager to commit 65bdab0, which is based on commit 5658f8c in Prometheus Alertmanager.

It applies the changes from grafana/alerting#155 which removes the overrides for validation of alerts, labels and silences that we had put in place to allow alerts and silences to work for non-Prometheus datasources. However, as this is now supported in Alertmanager with the UTF-8 work, we can use the new upstream functions and remove these overrides.

The compat package is a package in Alertmanager that takes care of backwards compatibility when parsing matchers, validating alerts, labels and silences. It has three modes: classic mode, UTF-8 strict mode, fallback mode. These modes are controlled via compat.InitFromFlags. Grafana initializes the compat package without any feature flags, which is the equivalent of fallback mode. Classic and UTF-8 strict mode are used in Mimir.

While Grafana Managed Alerts have no need for fallback mode, Grafana can still be used as an interface to manage the configurations of Mimir Alertmanagers and view configurations of Prometheus Alertmanager, and those installations might not have migrated or being running on older versions. Such installations behave as if in classic mode, and Grafana must be able to parse their configurations to interact with them for some period of time. As such, Grafana uses fallback mode until we are ready to drop support for outdated installations of Mimir and the Prometheus Alertmanager.
2024-02-06 08:33:47 +00:00
George Robinson 0726c7c3fa Alerting: Prevent inhibition rules in Grafana Alertmanager (#81712)
This commit prevents saving configurations containing inhibition
rules in Grafana Alertmanager. It does not reject inhibition
rules when using external Alertmanagers, such as Mimir. This meant
the validation had to be put in the MultiOrgAlertmanager instead of
in the validation of PostableUserConfig. We can remove this when
inhibition rules are supported in Grafana Managed Alerts.
2024-02-01 14:53:15 +00:00
George Robinson 05d858635c Alerting: Add metric for inhibition rules (#81119)
This commit adds a metric for the number of inhibition rules.
It matches the metric added upstream in #3681.
2024-01-23 19:43:17 +00:00
George Robinson 85b9edcd28 Alerting: Fix incorrect initialization of logger (#81099) 2024-01-23 17:29:38 +02:00
George Robinson f7c4909553 Fix incorrect example for PanelURL in template docs (#77755) 2023-11-07 08:57:10 +00:00
George Robinson 65398dabf4 Alerting: Update Alertmanager to latest main (70c52bf) (#77485) 2023-11-01 09:59:15 +00:00
George Robinson 5118ac9abd Update documentation for timezones in mute timings (#77370) 2023-10-30 17:28:01 +01:00
George Robinson ba384d29f6 Alerting: Fix order of the Alerting docs (#77084) 2023-10-24 19:31:03 +01:00
George Robinson 2c2d8bcc74 Alerting: Feedback on docs (#77068) 2023-10-24 16:53:26 +01:00
George Robinson 1cb1d174fd Alerting: Fix confusion around what can and cannot be customized in notifications (#77032)
* Alerting: Fix confusion around what can and cannot be customized in notifications

* Small fix

* Second small fix
2023-10-24 12:41:08 +01:00
George Robinson 272a901e5e Alerting: Improve order of docs pages (#76998) 2023-10-24 10:50:19 +01:00
George Robinson 0fc9da1422 Alerting: Improve documentation on high availability (#76434) 2023-10-24 10:15:38 +01:00
George Robinson 32f48ee64a Alerting: Fix link in docs (#76982) 2023-10-23 16:53:31 -05:00
George Robinson e94e283cc6 Alerting: Improve Introduction to Alerting docs (#76591) 2023-10-23 13:03:20 +03:00
George Robinson 622ecbb722 Alerting: Improve the docs for grouping and timers (#76589) 2023-10-23 09:48:24 +01:00
George Robinson e743aa54b8 Alerting: Improve the docs on templating labels and annotations (#76593)
The previous version of this page I wrote with the expectation that
readers would first learn the templating language and then write
their templates. This doesn't seem to have worked out as well as I
had expected, and so I've rewritten the documentation to explain
the language using relevant and useful examples instead.
2023-10-23 09:43:13 +01:00
George Robinson f9484fcf82 Alerting: Update grafana/alerting to a53b5db (#76679) 2023-10-17 12:55:39 +01:00
George Robinson 09a4fcd0fe Alerting: Add docs for Repeat interval (#76303) 2023-10-13 10:30:13 +01:00
George Robinson 05e12e787b Alerting: Add provenance field to /api/v1/provisioning/alert-rules (#76252)
This commit adds the missing Provenance field to responses for
/api/v1/provisioning/alert-rules.
2023-10-11 14:51:20 +01:00
George RobinsonandWilliam Wernert ed7d29f2b9 Alerting: Migrate old alerting templates to Go templates (#62911)
* Migrate old alerting templates to use $labels

* Fix imports

* Add test coverage and separate rewriting to Go templates

* Fix lint

* Check for additional closing braces

* Add logging of invalid message templates

* Fix tests

* Small fixes

* Update comments

* Panic on empty token

* Use logtest.Fake

* Fix lint

* Allow for spaces in variable names by not tokenizing spaces

* Add template function to deduplicate Labels in a Value map

* Fix behavior of mapLookupString

* Reference deduplicated labels in migrated message template

* Fix behavior of deduplicateLabelsFunc

* Don't create variable for parent logger

* Add more tests for deduplicateLabelsFunc

* Remove unused function

* Apply suggestions from code review

Co-authored by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>

* Give label val merge function better name

* Extract template migration and escape literal tokens

* Consolidate + simplify template migration

---------

Co-authored-by: William Wernert <william.wernert@grafana.com>
2023-10-02 11:25:33 -04:00
George Robinson 15f6e8a500 SQLStore: Fix race condition in RecursiveQueriesAreSupported (#75274) 2023-09-22 11:30:14 +01:00
George Robinson d7ed1e9379 Update Alertmanger to latest main (3513be6) (#75009)
* Update Alertmanager to latest main (3513be6)

* Fix validate-modfile
2023-09-19 10:16:34 +01:00
George Robinson 439270f6cb Rename Google Hangouts to Google Chat (#74162)
* Rename Google Hangouts to Google Chat

* Fix prettier
2023-08-31 16:09:22 +03:00
George Robinson 164161b41a Docs: Update docs on comparisions with $values (#74156) 2023-08-31 10:32:09 +01:00
George Robinson 972da629ab Update Alertmanager to latest main (6af7ccb) (#73827) 2023-08-25 15:08:09 +02:00
George Robinson 20172f6af1 Fix codeowners (#73829) 2023-08-25 15:42:08 +03:00
George Robinson 9f827a8278 Update grafana/alerting to 0025eb4 (#73808) 2023-08-25 15:20:17 +03:00
George Robinson bbef000202 Alerting: Add contact point for Grafana OnCall (#73733)
Add contact point for Grafana OnCall
2023-08-24 10:45:12 +02:00
George Robinson 7a9a869d86 Alerting: ScreenshotOptions From and To should be optional (#73325)
This commit updates the screenshot package to make From and To
optional. It also updates the docs for ScreenshotOptions so
this behavior is well documented.
2023-08-18 09:26:51 +01:00
George Robinson 892a0d2e5e Update logrus to v1.9.3 (#71571) 2023-07-21 09:37:20 +02:00
George Robinson 8dd3eb856d Alerting: Improve performance of matching captures (#71828)
This commit updates eval.go to improve the performance of matching
captures in the general case. In some cases we have reduced the
runtime of the function from 10s of minutes to a couple 100ms.
In the case where no capture matches the exact labels, we revert to
the current subset/superset match, but with a reduced search space
due to grouping captures.
2023-07-20 09:07:00 +01:00
George Robinson f1af0502db Alerting: Add tests for matching captures (#71928)
This commit adds tests for matching captures, which we do not have
at present.
2023-07-19 12:52:26 +01:00
George Robinson 89dcaaf049 Alerting: Sort NumberCaptureValues in EvaluationString (#71927)
This commit changes extractEvalString to sort NumberCaptureValues
in ascending order of Var before building the output string. This
means that users will see EvaluationString in a consistent order,
but also make it possible to assert its output in tests.
2023-07-19 12:09:21 +01:00
George Robinson 594c851d4b Alerting: Add duration to saving alert states done (#70844) 2023-06-28 15:19:21 +01:00
George Robinson 7edbe72483 Alerting: Support concurrent queries for saving alert instances (#70525)
This commit adds support for concurrent queries when saving alert
instances to the database. This is an experimental feature in
response to some customers experiencing delays between rule evaluation
and sending alerts to Alertmanager, resulting in flapping. It is
disabled by default.
2023-06-23 11:36:07 +01:00
George Robinson 404afedc25 Alerting: Adds in-app documentation for Classic Conditions (#70540)
This commit adds in-app documentation that explains using Classic
Conditions disables multi-dimensional alerts for the rule.
2023-06-22 19:29:54 +01:00
George Robinson 8a13ee3cd4 Alerting: Add debug logs when saving instances is finished (#70447) 2023-06-21 14:19:04 +02:00
George Robinson a1cb7319d5 Alerting: Update in app documentation for customizing message and subject (#70367) 2023-06-20 12:20:01 +02:00
George Robinson 815e98ed95 Alerting: Add debug logs for EndsAt timestamp (#70336)
This commit adds debug logs for previous_ends_at and next_ends_at
to state.go to help us debug issues where alerts are resolved in
Alertmanager due to expiration. This change is in response to a
support escalation where this information was needed but unavailable.
2023-06-20 12:13:38 +03:00
George Robinson 35d455e931 Show the alertname for each alert in plain text email (#70183) 2023-06-16 10:06:43 -04:00
George Robinson a773b722b1 Alerting: Fix newlines in text/plain template (#70207)
Alerting: Fix newlines in text/plain template at last
2023-06-16 09:02:58 +01:00
George Robinson a3845c9e2e Fix unwanted newlines in plain text email (#70141) 2023-06-15 15:04:10 +01:00
George Robinson f085e99d3c Alerting: Add matchers metrics to Alertmanager (#69855) 2023-06-15 09:18:01 +01:00
George Robinson 1154720df2 Run make in emails folder (#70113) 2023-06-15 01:24:43 +03:00
George Robinson c1e3362e21 Alerting: Fix email template for text/plain emails (#69951)
This commit fixes the email template for text/plain emails to
support custom messages. It also fixes the default template,
removing extra whitespace and showing Summary and Description
annotations separate from the other annotations.
2023-06-14 23:09:06 +01:00
George Robinson f80463a8a9 Alerting: Add heuristics back to datasource healthchecks (#69329)
This commit adds heuristics back to datasource healthchecks as
it was removed in #66198. The healthcheck for Prometheus datasources
also returns the kind (Prometheus or Mimir) and a boolean if the
ruler is enabled or disabled.
2023-06-05 10:35:18 +01:00
George Robinson 65e2df7a2e Docs: Add JSON format for webhook notifications to differences (#68786) 2023-05-25 10:08:36 +01:00
George Robinson d3bfaf549f Alerting: Update grafana/alerting to 4f09f51 (#67329) 2023-04-27 23:45:34 +03:00
George Robinson b71ef9b667 Alerting: Update grafana/alerting to fix #67177 (#67324) 2023-04-26 20:51:55 +01:00
George Robinson 35342a3c76 Alerting: Fix DatasourceUID and RefID missing for DatasourceNoData alerts (#66733)
This commit fixes a bug where DatasourceUID and RefID annotations are
missing for DatasourceNoData alerts in Grafana 9.5. This bug affects
datasource plugins that have moved to using the data plane contract.
2023-04-20 14:38:20 +01:00
George Robinson 883dcc81c0 Alerting: Add tests for Evaluate (#66739) 2023-04-20 11:24:40 +01:00
George Robinson 19ebb079ba Alerting: Add limits and filters to Prometheus Rules API (#66627)
This commit adds support for limits and filters to the Prometheus Rules
API.

Limits:

It adds a number of limits to the Grafana flavour of the Prometheus Rules
API:

- `limit` limits the maximum number of Rule Groups returned
- `limit_rules` limits the maximum number of rules per Rule Group
- `limit_alerts` limits the maximum number of alerts per rule

It sorts Rule Groups and rules within Rule Groups such that data in the
response is stable across requests. It also returns summaries (totals)
for all Rule Groups, individual Rule Groups and rules.

Filters:

Alerts can be filtered by state with the `state` query string. An example
of an HTTP request asking for just firing alerts might be
`/api/prometheus/grafana/api/v1/rules?state=alerting`.

A request can filter by two or more states by adding additional `state`
query strings to the URL. For example `?state=alerting&state=normal`.

Like the alert list panel, the `firing`, `pending` and `normal` state are
first compared against the state of each alert rule. All other states are
ignored. If the alert rule matches then its alert instances are filtered
against states once more.

Alerts can also be filtered by labels using the `matcher` query string.
Like `state`, multiple matchers can be provided by adding additional
`matcher` query strings to the URL.

The match expression should be parsed using existing regular expression
and sent to the API as URL-encoded JSON in the format:

{
    "name": "test",
    "value": "value1",
    "isRegex": false,
    "isEqual": true
}

The `isRegex` and `isEqual` options work as follows:

| IsEqual | IsRegex  | Operator |
| ------- | -------- | -------- |
| true    | false    |    =     |
| true    | true     |    =~    |
| false   | true     |    !~    |
| false   | false    |    !=    |
2023-04-17 17:45:06 +01:00
George Robinson 3e12b72f58 Alerting: Fix docs link when creating or editing rules (#66019) 2023-04-07 11:31:18 +00:00
George Robinson bd29071a0d Revert "Alerting: Add limits to the Prometheus Rules API" (#65842) 2023-04-03 15:20:37 +00:00
George Robinson d96b0a71d3 Alerting: Add limits to the Prometheus Rules API (#65169)
This commit adds a number of limits to the Grafana flavor of the
Prometheus Rules API:

1. `limit` limits the maximum number of Rule Groups returned
2. `limit_rules` limits the maximum number of rules per Rule Group
3. `limit_alerts` limits the maximum number of alerts per rule

It sorts Rule Groups and rules within Rule Groups such that data in the
response is stable across requests. It also returns summaries (totals) for
all Rule Groups, individual Rule Groups and rules.
2023-04-03 10:17:02 +01:00
George Robinson 0b506b4ccc Alerting: Update github.com/grafana/alerting (#64882) 2023-03-16 13:59:35 +00:00
George Robinson 1898e76dd6 Docs: Last iteration on docs for images in notifications (#64392)
This commit includes some minor rephrasing to the Requirements and
Limitations of the Images in notification feature.
2023-03-09 09:59:25 +00:00
George Robinson 0c8876c3a2 Alerting: Return errors when expanding templates (#63662)
This commit changes the state package so that errors encountered while
expanding templates for custom labels and annotations are returned
from the function. This is not used at present, but will be used in the
future as we look at how to offer better feedback to users who don't
have access to logs, for example our customers who use Hosted Grafana.
2023-03-08 12:25:02 +00:00
George Robinson 9d9421154e Docs: Update Images in notifications docs to be more readable and instructive (#64227) 2023-03-07 10:52:33 +00:00
George Robinson ed71012ced Alerting: Fix Classic Conditions $values variable (#64243)
This commit fixes a bug in the $values variable in notification
templates when using Classic Conditions. Since Classic Conditions
are not multi-dimensional, the values of each series that exceeded
the condition should be available as a RefID and offset. For example,
B0, B1, etc. However, this bug meant that instead just a single
condition would be printed as B, not B0.
2023-03-06 12:08:00 -05:00
George RobinsonandArmand Grillet fed59b1d43 Docs: Meta-monitoring docs for Grafana and Mimir (#63752)
* Docs: (WIP) Meta-monitoring docs for Grafana and Mimir

* Update metrics for Grafana Managed Alerts

* Fix spelling mistake

* Add docs for Alertamanager, including high-availability mode

* Comment undefined metrics

---------

Co-authored-by: Armand Grillet <2117580+armandgrillet@users.noreply.github.com>
2023-03-03 15:34:02 +01:00
George Robinson 030f6c948f Alerting: Fix migration pauses all alert rules on PostgreSQL (#63951)
This commit fixes a serious bug in Grafana 9.4.1 where on upgrade
a migration would pause all existing alert rules and change the
default value of the column to true.
2023-03-01 17:32:29 +00:00
George Robinson c9497dc533 Docs: Improved docs for templating labels and annotations (#63539) 2023-02-23 08:51:46 +00:00
George Robinson 18fec707fd Docs: Fix numbering in templating docs (#63577) 2023-02-22 17:36:00 +00:00
George Robinson 740bcf64ce Docs: Delete old templating notifications docs page (#63547) 2023-02-22 10:12:29 +00:00
George Robinson f93a9c794d Alerting: Fix incorrect comment in eval.go (#63510)
This commit fixes an incorrect comment in the Result struct in eval.go
that I had written some time ago. The comment now documents the
actual behaviour and content of this field.
2023-02-21 15:42:04 +00:00
George Robinson 85457156e3 Docs: Remove duplicate docs on images in notifications (#63474) 2023-02-20 12:58:04 -05:00
George Robinson 0e9201c522 Docs: Uploading images from disk supported in Slack (#63443) 2023-02-20 17:39:10 +00:00
George Robinson 92248fe977 Docs: Upload images from disk supported in Telegram (#63442) 2023-02-20 18:33:19 +01:00
George Robinson 9f2fb3fa27 Alerting: Add filter and remove funcs for custom labels and annotations (#63437)
This commit adds filterLabels, filterLabelsRe, removeLabels, and
removeLabelsRe functions to templates for custom labels and annotations.
It allows for use cases such as removing all private labels.
2023-02-20 14:40:26 +00:00
George Robinson c637a5543e Alerting: Rename caps to captures as cap is a reserved word (#63432) 2023-02-20 10:08:36 +00:00
George Robinson aacf9da969 Alerting: Change Data to use Labels instead of map[string]string (#63431)
This commit changes the Data struct in template.go to use Labels
instead of map[string]string. It changes how labels are printed
when using {{ .Labels }} from map[foo:bar bar:baz] to
foo=bar, bar=baz.
2023-02-20 10:08:23 +00:00
George Robinson 005f5ca1df Alerting: Fix confusing comment about screenshots in default.ini and docs (#63346) 2023-02-20 09:59:45 +00:00
George Robinson 0a01391ebe Alerting: Small readability improvements to template.go (#63422)
* Alerting: Small readability improvements to template.go

* Fix lint
2023-02-20 09:24:11 +00:00
George Robinson 0659134793 Alerting: Better printing of labels (#63348)
This commit changes how labels are printed in templates for custom
annotations and labels from map[foo:bar bar:baz] to foo=bar, bar=baz.
Labels are comma separated, and sorted in increasing order.
2023-02-16 12:04:15 -05:00
George Robinson 9e86916d48 Alerting: Move templating to template package (#63347)
This commit moves templating from the state package to a sub-package
called template. This sub-package will be the logical package for
future ease-of-use improvements to templating custom annotations
and labels.
2023-02-16 17:16:36 +01:00
George Robinson 1f984409a2 Alerting: Fix a bug taking screenshots with Dashboard UID (#63220)
This commit fixes a bug where Grafana would fail to take a screenshot if
the same Dashboard UID was present across two or more different orgs.
2023-02-09 15:23:01 -05:00
George Robinson f49efa6e27 Alerting: Pause dash alerts on migration (#62798)
* Alerting: Pause dash alerts on migration
2023-02-02 16:49:05 -05:00
George RobinsonandGilles De Mey 0dacb11a12 Alerting: Validate that tags are 100 characters or less (#62335)
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
2023-01-31 14:19:44 +00:00
George Robinson b6db1ed524 Revert "Alerting: Add is_paused attr to the POST alert rule group endpoint" (#62310)
Revert "Alerting: Add is_paused attr to the POST alert rule group endpoint (#62253)"

This reverts commit 3ccafe3a5a.
2023-01-27 13:41:36 +01:00
George Robinson a7eab8e46e Alerting: Support context.Context in Loki interface (#61979)
This commit adds support for canceleable contexts in the Loki
interface.
2023-01-26 09:31:20 +00:00
George Robinson 239d94205a Alerting: Return chan <-error for #61811 (#61858) 2023-01-24 15:41:38 +00:00
George Robinson d4256b352d Docs: Rename Message templates to Notification templates (#59477)
This commit renames "Message templates" to "Notification templates"
in the user interface as it suggests that these templates cannot
be used to template anything other than the message. However, message
templates are much more general and can be used to template other fields
too such as the subject of an email, or the title of a Slack message.
2023-01-18 17:26:34 +00:00
George Robinson fa9f1c3a52 Docs: Re-order nav for Manage your alert notifications (#60897) 2023-01-11 08:44:01 +00:00
George Robinson 2a291afbae Alerting: Use consts from alerting package (#61241) 2023-01-10 19:59:13 +00:00
George Robinson d19d8c6625 Alerting: Update Alerting and Alertmanager to v0.25.1 (#61233)
Update Alerting and Alertmanager to v0.25.1
2023-01-10 16:17:07 +00:00
George Robinson 35ad9e23ce Docs: Update weights for Customize notifications without changing the order of pages (#60898) 2023-01-10 11:07:00 +00:00
George Robinson 402dc5e4d6 Alerting: Redo refactoring from reverted fix in #56812 (#61051)
This pull request re-applies the refactoring of ConditionsCmd from a
reverted fix #56812 for mathexp.noData. It does not add the fix, or
tests for the fix, because those were added in #56816. We use the
additional test coverage added in #56816 and #58650 to avoid the
reoccurrence of regressions that caused us to revert #56812 the
first time.
2023-01-09 17:01:19 +00:00
George Robinson 9af7adef76 Alerting: Support customizable timeout for screenshots (#60981)
This commit adds a customizable timeout for screenshots called
capture_timeout. The default value is 10 seconds, and the maximum
value is 30 seconds. This timeout should be less than the minimum
Interval of all Evaluation Groups to avoid back pressure on alert
rule evaluation.
2023-01-05 16:07:46 +00:00
George Robinson 1a442de094 Docs: Rephrase opening sentence for Customize notifications (#60560) 2022-12-21 10:51:02 +00:00
George Robinson 5d4e35c3d5 Docs: Fix links in Using Go's templating language (#60564) 2022-12-20 12:30:43 +00:00
George Robinson d7b555c405 Docs: Remove old message templates documentation (#60548) 2022-12-20 08:23:42 +00:00
f6aea16894 Docs: Templating notifications (#60109)
* Docs: Templating notifications

* Feedback

* More feedback

* Edit template notifications

* More edits

* Fix typo

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: Armand Grillet <2117580+armandgrillet@users.noreply.github.com>
2022-12-19 15:01:18 +00:00