Commit Graph

1560 Commits

Author SHA1 Message Date
Matthew Jacobson
32f06c6d9c
Alerting: Receiver API complete core implementation (#91738)
* Replace global authz abstraction with one compatible with uid scope

* Replace GettableApiReceiver with models.Receiver in receiver_svc

* GrafanaIntegrationConfig -> models.Integration

* Implement Create/Update methods

* Add optimistic concurrency to receiver API

* Add scope to ReceiversRead & ReceiversReadSecrets

migrates existing permissions to include implicit global scope

* Add receiver create, update, delete actions

* Check if receiver is used by rules before delete

* On receiver name change update in routes and notification settings

* Improve errors

* Linting

* Include read permissions are requirements for create/update/delete

* Alias ngalert/models to ngmodels to differentiate from v0alpha1 model

* Ensure integration UIDs are valid, unique, and generated if empty

* Validate integration settings on create/update

* Leverage UidToName to GetReceiver instead of GetReceivers

* Remove some unnecessary uses of simplejson

* alerting.notifications.receiver -> alerting.notifications.receivers

* validator -> provenanceValidator

* Only validate the modified receiver

stops existing invalid receivers from preventing modification of a valid
receiver.

* Improve error in Integration.Encrypt

* Remove scope from alert.notifications.receivers:create

* Add todos for receiver renaming

* Use receiverAC precondition checks in k8s api

* Linting

* Optional optimistic concurrency for delete

* make update-workspace

* More specific auth checks in k8s authorize.go

* Add debug log when delete optimistic concurrency is skipped

* Improve error message on authorizer.DecisionDeny

* Keep error for non-forbidden errutil errors
2024-08-26 10:47:53 -04:00
Julien Duchesne
3ac8760321
OpenAPI: Fix ValidationError message attribute (#90846)
It's `message`, not `msg`. It's been fixed for a while here: 9ef6983612/scripts/pull-schema.sh (L46-L49)

I've also reflected the change in the tests
2024-08-26 10:05:37 -04:00
Julien Duchesne
087df1d8e5
OpenAPI: Fix alerting DeleteMuteTiming errors (#91109)
The `GenericPublicError` is not what is actually returned by the API. Using `PublicError` describes the API correctly
2024-08-26 10:04:36 -04:00
Julien Duchesne
0075abe383
OpenAPI: Fix ProvisionedAlertRule.for type (#90841)
This override has been in the client for a while now: 9ef6983612/scripts/pull-schema.sh (L34-L39)

The API expects a string here and transforms it to a duration internally
2024-08-26 10:04:15 -04:00
Tito Lins
4a124469fa
Check is config is default by comparing hashes (#92296) 2024-08-23 11:22:06 +02:00
Christian Inkster
922babb157
Alerting: Add mutex to Redis HA subs (#89870) 2024-08-22 16:01:33 +01:00
Alexander Akhmetov
832bb01f36
Alerting: Add MQTT notifications receiver (#91487)
* Alerting: Add MQTT notifications receiver
* Update alerting to 9daa6239cc41dc42bff0e916c8d0d27766caa8b9 (main)
---------

Co-authored-by: Jack Baldry <jack.baldry@grafana.com>
Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
2024-08-22 16:47:48 +02:00
William Wernert
dfbddd8262
Alerting: Fix recording rule export (#91405)
* Fix HCL export

* Update rule export struct to support new optional fields

* Omit `for` field in export API if empty
2024-08-22 09:04:21 -04:00
Dave Henderson
df3d8915ba
Chore: Bump Go to 1.23.0 (#92105)
* chore: Bump Go to 1.23.0

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* update swagger files

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* chore: update .bingo/README.md formatting to satisfy prettier

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* chore(lint): Fix new lint errors found by golangci-lint 1.60.1 and Go 1.23

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* keep golden file

* update openapi

* add name to expected output

* chore(lint): rearrange imports to a sensible order

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

---------

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2024-08-21 11:40:42 -04:00
Fayzal Ghantiwala
8d725a641c
Alerting: Integration test for testing template via remote alertmanager (#92147)
* Add integration test for testing template

* Update drone signature
2024-08-21 13:06:01 +01:00
Yuri Tseretyan
d27c3822f2
Alerting: Add Create and Update methods to Template service (#91981)
* rename SetTemplate to UpsertTemplate

* Introduce Create\Update methods

* update api endpoint to use GetTemplate
2024-08-20 15:23:01 -04:00
Alexander Akhmetov
d32e1e009b
Alerting: Update prometheus/client_golang to v1.20 (#92070)
Update prometheus/client_golang to v1.20
2024-08-20 11:26:06 +02:00
Alexander Weaver
ac5ebe6e4d
Alerting: Add enablement flag for recording rules (#92032)
* Add enablement flag

* Disable if toggle not enabled
2024-08-19 12:01:00 -05:00
Yuri Tseretyan
135f6571a9
Alerting: Update Time Interval service to support renaming of resources (#91856)
* add RenameTimeIntervalInNotificationSettings to storage
* update dependencies when the time interval is renamed
---------

Co-authored-by: William Wernert <william.wernert@grafana.com>
2024-08-16 20:55:03 +03:00
Fayzal Ghantiwala
e321dbb690
Alerting: Use remote Alertmanager to test templates and receivers when enabled (#91570)
* Initial impl

* Add code to test templates and receivers

* Fix linter

* Fix forked am tests

* Update mimir client

* Remove trailing whitespace

* re-trigger CI
2024-08-15 16:56:14 +01:00
Santiago
f852bf684a
Alerting: Fix duplicated silences in remote primary mode bug (#91902)
* Alerting: Fix duplicated silences in remote primary mode bug

* test that a new silence id returned by calling CreateSilence() on the internal Alertmanager is ignored
2024-08-15 17:14:55 +02:00
Yuri Tseretyan
5834981f86
Alerting: Add GetTemplate to template service and update tests (#91854)
* add GetTemplate to template service
* refactor GetTemplates to fetch all provenances at once
* refactor tests
2024-08-15 09:17:48 -04:00
Alexander Akhmetov
c7fdf8ce70
Alerting: Add error to annotations on data source errors (#91594) 2024-08-15 12:34:50 +02:00
Alexander Weaver
34ab5fe1f3
Alerting: Restart rule routines if the type changes (#90867)
* Restart when types change

* Wire up test hooks correctly

* testing
2024-08-14 14:57:47 -05:00
Yuri Tseretyan
7b919e3277
Alerting: MuteTimeService to support TimeInterval and MuteTimeInterval fields in Alertmanager config (#91500)
* update notification policy provisioing to consider time intervals
* change names of intervals to be in order
2024-08-13 11:37:21 -04:00
Yuri Tseretyan
db33df5041
Alerting: Template API to return errutil errors (#91821) 2024-08-13 10:59:19 -04:00
Alexander Akhmetov
149f02aebe
Alerting: Add rule_group label to grafana_alerting_rule_group_rules metric (#88289)
* Alerting: Add rule_group label to grafana_alerting_rule_group_rules metric (#62361)

* Alerting: Delete rule group metrics when the rule group is deleted

This commit addresses the issue where the GroupRules metric (a GaugeVec)
keeps its value and is not deleted when an alert rule is removed from the rule registry.
Previously, when an alert rule with orgID=1 was active, the metric was:

  grafana_alerting_rule_group_rules{org="1",state="active"} 1

However, after deleting this rule, subsequent calls to updateRulesMetrics
did not update the gauge value, causing the metric to incorrectly remain at 1.

The fix ensures that when updateRulesMetrics is called it
also deletes the group rule metrics with the corresponding label values if needed.
2024-08-13 13:27:23 +02:00
Alexander Akhmetov
b2eeb0dd6e
Alerting: update rule versions on folder move (#88376)
* Alerting: update rule versions on folder move (#88361)
* Add tracing to folder.Move and folder.Update
2024-08-13 12:26:26 +02:00
Karl Persson
8bcd9c2594
Identity: Remove typed id (#91801)
* Refactor identity struct to store type in separate field

* Update ResolveIdentity to take string representation of typedID

* Add IsIdentityType to requester interface

* Use IsIdentityType from interface

* Remove usage of TypedID

* Remote typedID struct

* fix GetInternalID
2024-08-13 10:18:28 +02:00
Konrad Lalik
b67bcdb9b8
Alerting: Handle namespace and group query string params in Ruler API (#91533)
* Handle namespace and group query string params in Ruler API

* Use the new namespace and group query params when slashes in names

* Add validation, add group handling in GMA Api

* Move constants

* Use checkForPathSeparator function

* Fix linter issue
2024-08-13 08:31:07 +02:00
Fayzal Ghantiwala
25dbb32cea
Alerting: Vendor in latest grafana/alerting package (#91786)
* temp

* vendor

* Remove dead code

* Vendoring
2024-08-12 15:37:15 +01:00
Santiago
5487ea444a
Alerting: Update remote Alertmanager config marshalling in test (#91791) 2024-08-12 13:45:22 +02:00
Yuri Tseretyan
1108a00668
Alerting: Support for optimistic concurrency in priovisioning Tempate API (#91195)
* support optimistic concurrency in template service

* update request handler to get version from query parameter

* return not found if a new template is set with version

* update PUT api to set version

* update documentation + for mute timings

---------

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
2024-08-09 11:40:07 -04:00
Karl Persson
bcfb66b416
Identity: remove GetTypedID (#91745) 2024-08-09 18:20:24 +03:00
Kristin Laemmert
a117b090cf
chore: preallocate slices where we have a good idea of requirements (#91596)
* chore: preallocate slices where we have a good idea of requirements

* pr feedback
2024-08-07 08:34:52 -04:00
Yuri Tseretyan
ee78bb653f
Alerting: Log rule evaluation error in scheduler (#91585) 2024-08-06 19:27:02 +03:00
Matthew Jacobson
53cfdf0ef8
Alerting: Remove option to return settings from api/v1/receivers and restrict provisioning action access (#90861)
* Remove provisioning action access to v1/receivers api

* Separate ListOnly functionality to its own method without decryption
2024-08-05 11:49:23 -04:00
AvivGuiser
93aa5a56ad
Alerting: Use stable identifier of a group,contact point,mute timing when export to HCL (#90917)
---------

Signed-off-by: Aviv Guiser <avivguiser@gmail.com>
2024-08-05 09:56:17 -04:00
Matthew Jacobson
a397bca02e
Alerting: Fix panic with nil annotations & Nodata=alerting/ok/keep (#91506) 2024-08-02 22:15:57 +03:00
Alexander Weaver
72ecde5045
Alerting: Make orgID a direct arg of writer interface (#91422)
make orgID a direct arg of writer interface
2024-08-02 09:37:28 -05:00
Alexander Akhmetov
3952f627eb
Alerting: Parse secret fields case-insensitively when creating or updating a contact point (#90968)
* Alerting: Handle case-insensitive secret fields in contact point settings
2024-08-01 19:03:47 +02:00
William Wernert
a1ee84f757
Alerting: Remove duplicate tracing middleware from prom writer (#91353)
Remove duplicate tracing middleware from prom writer
2024-08-01 11:57:14 -04:00
Ieva
2e2ddc5c42
Folders: Allow folder editors and admins to create subfolders without any additional permissions (#91215)
* separate permissions for root level folder creation and subfolder creation

* fix tests

* fix tests

* fix tests

* frontend fix

* Update pkg/api/accesscontrol.go

Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>

* fix frontend when action sets are disabled

---------

Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>
2024-08-01 18:20:38 +03:00
Yuri Tseretyan
537f1fb857
Alerting: Fix persisting result fingerprint that is used by recovery threshold (#91224)
* fix persister to save result fingerprint

* revert change

* fmt
2024-07-30 18:07:13 -04:00
Nihal
9ad9b4989b
Alerting: Include a list of ref_Id and aggregated datasource UIDs to alerts when state reason is NoData (#88819)
* include a list of ref_Id and datasource UID to alerts when state reason is NoData. 

---------

Signed-off-by: Syed Nihal <syed.nihal@nokia.com>
2024-07-30 12:55:59 -04:00
Alexander Weaver
4c71cadd5f
Alerting: Detach condition validator from condition evaluator (#91150)
* Detach validator from evaluator

* Drop unnecessary interface and type
2024-07-30 10:55:37 -05:00
github-actions[bot]
66b1a219f4
Alerting: Update Swagger spec (#79850)
* chore: update alerting swagger spec
* update public swagger

---------

Co-authored-by: rwwiv <rwwiv@users.noreply.github.com>
Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
2024-07-30 18:17:23 +03:00
Yuri Tseretyan
2023821100
Alerting: update Loki backend of state history to batch requests by folder (#89865)
* refactor `selectorString` and remove Selector struct

* move code from selector string to BuildLogQuery

* batch requests by folder UID

* update historian annotation store to handle multiple queries

* sort folder uids to make consistent queries

* add logs to loki http

* log batch size but not content. content is logged by the client
2024-07-30 11:07:10 -04:00
Yuri Tseretyan
8323b688c6
Alerting: Improve logging in scheduler and states (#91003)
* handle metadata map nil

* remove double context

* clean up logging in scheduler

* do not reuse loggers from previous ticks

* log the dropped tick

* log tick instead of ticknum

* replace with processing tick logs

* log sending notifications

* update logging in persister to fetch context

* logs to historian

moved them upstream to be able to log when store is overridden
2024-07-29 16:01:48 -04:00
Matthew Jacobson
62f67e38b8
Alerting: Implement receiver auth service (#90857) 2024-07-29 15:49:10 -04:00
Yuri Tseretyan
34dbfefc86
Alerting: Template service to check for provenance status of update\delete (#90688) 2024-07-29 14:10:03 -04:00
Matthew Jacobson
a1f0b599a7
Alerting: Refactor receiver_svc and provisioning config store into legacy_storage package (#90856)
* Add more receivers api tests

* Move provisioning config store to new legacy_storage package
2024-07-26 17:45:33 -04:00
Yuri Tseretyan
6b0d20c96a
Alerting: time interval service to support addressing intervals by Base64 encoded name (#90563)
* rename to getMuteTimingByName

* add UID to api model of MuteTiming

* update GetMuteTiming to search by UID

* update UpdateMuteTiming to support search by UID

* update DeleteMuteTiming to support uid

* make sure UID is populated

* update usages

* use base64 url-safe, no padding encoding for UID
2024-07-26 16:43:40 -04:00
Alexander Weaver
b7220b532e
Alerting: Fix bug where patching recording rule queries wouldn't apply (#91011)
* the fix

* tests
2024-07-26 11:02:54 -05:00
Ryan McKinley
be7b1ce2df
Chore: Replace appcontext.User(ctx) with identity.GetRequester(ctx) (#91030) 2024-07-26 16:39:23 +03:00