Commit Graph

476 Commits

Author SHA1 Message Date
Steve Simpson
e9fd191065
Alerting: Fix some status codes returned from provisioning API. (#90117)
The contact point deletion API was returning 500 when it should have been
returning a 4xx error, when the contact point is in use:

- When in use by a notificiation policy, we were missing
  the `.Errorf("")` to convert `errutil.Base` into `errutil.Error`.
- When in use by an alert rule, an regular error was returned.
2024-07-05 19:06:37 +02:00
Alexander Zobnin
87d86e81ce
Zanzana: Evaluate permissions alongside with RBAC engine (#90064)
* Zanzana: Evaluate permissions if feature flag enabled

* Fix tests

* adjust logs

* fix spelling

* remove unused

* only evaluate implemented resources

* refactor
2024-07-05 11:31:23 +02:00
Ryan McKinley
de06762852
K8s: Add basic peakq test w/ resource (#90026) 2024-07-04 01:26:33 +03:00
Andres Martinez Gotor
a22c1ae424
Chore: Remove provisional APIVersion from plugin info (#89831) 2024-07-01 10:53:16 +02:00
Ryan McKinley
3db4e5a0c6
K8s: remove dashboard summary abstraction (#89761) 2024-06-26 15:00:24 +03:00
Ryan McKinley
4651506319
K8s/Dashboards: Replace multiple calls with a single endpoint (#89639) 2024-06-26 07:27:52 +03:00
Ryan McKinley
93ef90a1e4
K8s: remove (not great) example api (#89524) 2024-06-21 10:23:08 +03:00
Yuri Tseretyan
b075926202
Alerting: Time Intervals API (#88201)
* expose ngalert API to public
* add delete action to time-intervals
* introduce time-interval model generated by app-platform-sdk from CUE model the fields of the model are chosen to be compatible with the current model
* implement api server
* add feature flag alertingApiServer
---- Test Infra
* update helper to support creating custom users with enterprise permissions
* add generator for Interval model
2024-06-20 16:52:03 -04:00
Ryan McKinley
9b7f9ae22e
K8s: Rename origin.key to origin.hash (#89337) 2024-06-18 22:27:16 +03:00
Steve Simpson
dd3c3b5857
Alerting: Update grafana/alerting. (#88914) 2024-06-14 09:19:04 +02:00
Ryan McKinley
99d8025829
Chore: Move identity and errutil to apimachinery module (#89116) 2024-06-13 07:11:35 +03:00
Yuri Tseretyan
d4b0ac5973
Alerting: Fix rule storage to filter by group names using case-sensitive comparison (#88992)
* add test for the bug
* remove unused struct
* update db store to post process filters by group using go-lang's case-sensitive string comparison

--------

Co-authored-by: Alexander Weaver <weaver.alex.d@gmail.com>
2024-06-10 19:05:47 -04:00
Leonor Oliveira
b30c81b1ad
Add and fix tests for playlists in mode1 (#88543)
* Add and fix tests for playlists in mode1

* Make etcd tests pass mode1 for now

* Fix mode1 and add more tests for playlists in mode 1

* Remove repeated test

* Fix test setup
2024-06-10 16:11:01 +02:00
Piotr Jamróz
0a05ac6aed
Correlations: Remove flakey test (#88912)
* Make the flakiness error more verbose

* Fix linting

* Remove a flaky test and make assertion failures more verbose
2024-06-10 15:14:38 +02:00
David Harris
60bec80672
Cloudwatch: add keywords (#88855)
---------

Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
2024-06-10 08:11:47 -04:00
Yuri Tseretyan
003e3efce9
Alerting: Update mute timings provisioning API to support optimistic locking (#88731)
* add version to time-interval models
* set time interval fingerprint as version
* update to check provided version
* delete to check if version is provided in query parameter 'version'
* update integration tests
* update specs
2024-06-06 18:06:37 -04:00
Dave Henderson
e21d357d67
chore: Updating linter, fixing some new warnings (#88863) 2024-06-06 13:01:27 -04:00
Carl Bergquist
16cc75b02c
Scopes: Add Handler for returning dashboards related to a list of scopes. (#87758)
- Adds a find endpoint to return dashboard bindings that match any of the scopes. For example /apis/scope.grafana.app/v0alpha1/namespaces/default/find/scope_dashboard_bindings?scope=s1&scope=s2
- Updates the ScopeNode find endpoint to a new path, /find/scope_node_children , makes the key "items" for all find endpoints (instead of mix of "found" and "items"), and makes the list item type a ScopeNode instead of its own type.
- Updates kubectl get commands to return more information about scopes, scopenodes, and scopedashboard bindings to display more fields in table output

---------

Signed-off-by: bergquist <carl.bergquist@gmail.com>
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
Co-authored-by: Kyle Brandt <kyle@grafana.com>
Co-authored-by: Todd Treece <todd.treece@grafana.com>
2024-06-05 11:47:36 -04:00
Santiago
9f9928d41a
Alerting: Update grafana/alerting (#88363)
* Alerting: Update grafana/alerting

* make tests pass by implementing yaml unmarshallers and deleting fields with omitempty in their yaml tags

* go mod tidy

* fix tests by implementing not calling GettableApiAlertingConfig.UnmarshalYAML from GettableApiAlertingConfig.UnmarshalJSON

* cleanup, reduce diff

* fix more tests

* update grafana/alerting to latest commit, delete global section from configs in tests

* bring back YAML unmarshaller for GettableApiAlertingConfig

* update alerting package dependency to point to main

* skip test for sns notifier
2024-06-04 20:29:37 +02:00
Carl Bergquist
c99fe4f970
Scopes: Add DashboardTitle to scopedashboardbinding (#88609)
scopes: add title to scopedashboardbinding

Signed-off-by: bergquist <carl.bergquist@gmail.com>
2024-06-04 10:36:03 +03:00
Arati R
36f42853dd
Storage: Read desired mode from config instead of feature flags (#88353)
* Read desired mode from config
* Update playlist integration tests
* Add mode 1 playlist integration tests
* Add mode 0 dual writing to playlist integration tests
* Add documentation for the different dual writing modes
2024-05-31 19:29:59 +02:00
Sofia Papagiannaki
17ca61d7f8
Alerting: Export and provisioning rules into subfolders (#77450)
* Folders: Optionally include fullpath in service responses
* Alerting: Export folder fullpath instead of title
* Escape separator in folder title
* Add support for provisiong alret rules into subfolders
* Use FolderService for creating folders during provisioning
* Export WithFullpath() folder service function

---------

Co-authored-by: Tania B <yalyna.ts@gmail.com>
Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
2024-05-31 11:09:20 +03:00
Eric Leijonmarck
910553df20
Actionsets: Add cfg option for only writing actionsets (#88367)
* test

* test

* missed test

* fix review comments
2024-05-28 16:32:23 +01:00
Ryan McKinley
ffc2702552
Plugins: Support Admission validation hooks (#87718) 2024-05-24 18:45:16 +03:00
Gaurav Agrawal
fdaa091a4d
Alerting: Support custom API URL for PagerDuty integration (#88007)
* fix assert in LINE
* fix pagerduty asserts

---------

Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
2024-05-22 15:31:55 -04:00
Alexander Weaver
49c8deb1ea
Alerting: Add recording rules to ruler API and validation (#87779)
* Read path, main API

* Define record field for incoming requests

* Refactor several alerting specific validators into two paths

* Refactor validateCondition actually contain all the condition validation logic

* Move condition validation inside rule path

* Validators for recording rules

* Wire feature flag through to validators

* Test for accepting a valid recording rule

* Tests for negative case, no UID

* Test for ignoring alerting fields

* Build conditions based on recording rules as well

* Regenerate swagger docs

* Fix CRUD test to cover the right thing

* Re-generate swagger docs with backdated v0.30.2 version

* Regenerate base spec

* Regenerate ngalert specs

* Regenerate top level specs

* Comment and rename

* Return struct instead of modifying ref
2024-05-21 14:39:28 -05:00
Ryan McKinley
6d10797812
Errors: Update errutil to be compatible with k8s errors (#87605) 2024-05-20 18:11:37 +03:00
Piotr Jamróz
d09f5abec9
Correlations: improve error handling (#87810)
Improve error handling
2024-05-20 10:35:47 +02:00
Arati R
4867fd3069
Storage: Test mode 2 dual writer in playlist tests (#87938)
Add mode 2 feature flag to playlist tests
2024-05-16 10:39:30 +02:00
Kyle Brandt
ea1845edbe
Scopes: Change JS linkID to linkId (#87831) 2024-05-14 11:01:21 -04:00
Andres Martinez Gotor
d8904f3ca4
Add apiVersion to plugin models (#87510) 2024-05-14 13:58:27 +02:00
Kyle Brandt
ff6d1f4977
Scopes: Add intregation tests for scopeNodes based on example (#87646) 2024-05-13 14:12:33 -04:00
Ryan McKinley
f880abc292
QueryService: Move raw http.Handler to rest.Connector (#87595)
* query connector

* improve error wrappers

* return 400 for missing datasource (not 404)

* fix errors

* message
2024-05-10 21:01:17 +03:00
Ieva
105313f5c2
RBAC: Adding action set resolver for RBAC evaluation (#86801)
* add action set resolver

* rename variables

* some fixes and some tests

* more tests

* more tests, and put action set storing behind a feature toggle

* undo change from cfg to feature mgmt - will cover it in a separate PR due to the amount of test changes

* fix dependency cycle, update some tests

* add one more test

* fix for feature toggle check not being set on test configs

* linting fixes

* check that action set name can be split nicely

* clean up tests by turning GetActionSetNames into a function

* undo accidental change

* test fix

* more test fixes
2024-05-09 10:18:03 +01:00
Todd Treece
6e4d35e1ee
Scopes: Add a /find query endpoint (#87457)
---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2024-05-08 13:35:11 -04:00
Leonor Oliveira
ee2f6a7b49
Force interface implementation also on legacy storage (#87414)
* Force interface implementation also on legacy storage

* Add DeleteCollection to folders and dashboards

* Fix integration tests

* Fix tests
2024-05-07 15:02:30 +02:00
Matthew Jacobson
babfa2beac
Alerting: Hook up GMA silence APIs to new authentication handler (#86625)
This PR connects the new RBAC authentication service to existing alertmanager API silence endpoints.
2024-05-03 15:32:30 -04:00
Carl Bergquist
7a6bef8f9c
Scopes: Adds kinds for browsing the scope node tree. (#86975)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
2024-05-03 09:48:54 +02:00
Karl Persson
a2cba3d0b5
User: Add tracing (#87028)
* Inject tracer in tests

* Annotate with traces

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
2024-04-30 13:15:56 +02:00
Ieva
cee713e34c
Chore: Add tracing to team service (#86999)
* add tracing to team service

* another test fix

* pass in context for team creation and membership checking
2024-04-29 11:32:03 +01:00
Timur Olzhabayev
951916c668
Chore: Making the plugin install commands respect the config parameter (#86578)
Currently the grafana cli plugin commands are not reacting to the --config parameter. This PR make it possible to use config to define the plugin endpoints via config as an alternative to providing the --repo flag.
2024-04-22 10:29:25 +02:00
Steve Simpson
6ea97e41fb
Alerting: Consistently return Prometheus-style responses from rules APIs. (#86600)
* Alerting: Consistently return Prometheus-style responses from rules APIs.

This commit is part refactor and part fix. The /rules API occasionally returns
error responses which are inconsistent with other error responses. This fixes
that, and adds a function to map from Prometheus error type and HTTP code.

* Fix integration tests

* Linter happiness

* Make linter more happy

* Fix up one more place returning non-Prometheus responses
2024-04-19 21:03:20 +02:00
Eric Leijonmarck
ddabef9895
RBAC: Add actionsets struct and write path (#86108)
* Add actionsets struct and failing test

* update from review

* review comments

* review comments update

* refactor: create interface

* actionset service

* fix tests

* move from wireoss to wire

* Apply suggestions from code review

remove unnecessary comments

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>

* nil for the actionsetservice

* Revert "nil for the actionsetservice"

This reverts commit e3d3cc8171.

---------

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2024-04-19 15:38:14 +01:00
Matthew Jacobson
533bed6d94
Alerting: Fix simplified routes '...' groupBy creating invalid routes (#86006)
* Alerting: Fix simplified routes '...' groupBy creating invalid routes

There were a few ways to go about this fix:
1. Modifying our copy of upstream validation to allow this
2. Modify our notification settings validation to prevent this
3. Normalize group by on save
4. Normalized group by on generate

Option 4. was chosen as the others have a mix of the following cons:
- Generated routes risk being incompatible with upstream/remote AM
- Awkward FE UX when using '...'
- Rule definition changing after save and potential pitfalls with TF

With option 4. generated routes stay compatible with external/remote AMs, FE
doesn't need to change as we allow mixed '...' and custom label groupBys, and
settings we save to db are the same ones requested.

In addition, it has the slight benefit of allowing us to hide the internal
implementation details of `alertname, grafana_folder` from the user in the
future, since we don't need to send them with every FE or TF request.

* Safer use of DefaultNotificationSettingsGroupBy

* Fix missed API tests
2024-04-16 12:14:39 -04:00
Gábor Farkas
2379498228
mysql additional decoupling steps (#86168)
* mysql additional decoupling steps

* updated snapshot test
2024-04-16 11:50:41 +02:00
Karl Persson
895222725c
Session: set authID and authenticatedBy (#85806)
* Authn: Resolve authenticate by and auth id when fethcing signed in user

* Change logout client interface to only take Requester interface

* Session: Fetch external auth info when authenticating sessions

* Use authenticated by from identity

* Move call to get auth-info into session client and use GetAuthenticatedBy in various places
2024-04-11 10:25:29 +02:00
Dan Cech
5dfe4cf407
Storage: Watch tests (#85496)
* basic watch tests working

* refactor to read previous event within poller

* add watch test files

* cleanup

* watch tests passing

* debug cleanup

* special handling for canceled context

* cleanup

* fix wire

* fix sqlite_sequence cleanup issue

* move watch tests to integration, wait for provisioned dashboards

* handle context deadline exceeded and eof errors

* add comment about sleep
2024-04-08 11:42:12 -04:00
Santiago
6a75a8f354
Alerting: Update grafana/alerting and use Upsert for creating silences (#85676)
* Alerting: Update grafana/alerting and use Upsert for creating silences

* go.work.sum

* change error message in tests for silences (save -> upsert)
2024-04-08 11:46:14 +02:00
Sofia Papagiannaki
88be09420c
Chore: Fix test to retry fetching provisioned dashboard until is in place (#85408)
Retry fetching provisioned dashboard until is in place
2024-04-08 10:47:34 +03:00
Serge Zaitsev
faa1244518
Chore: Replace sqlstore with db interface (#85366)
* replace sqlstore with db interface in a few packages

* remove from stats

* remove sqlstore in admin test

* remove sqlstore from api plugin tests

* fix another createUser

* remove sqlstore in publicdashboards

* remove sqlstore from orgs

* clean up orguser test

* more clean up in sso

* clean up service accounts

* further cleanup

* more cleanup in accesscontrol

* last cleanup in accesscontrol

* clean up teams

* more removals

* split cfg from db in testenv

* few remaining fixes

* fix test with bus

* pass cfg for testing inside db as an option

* set query retries when no opts provided

* revert golden test data

* rebase and rollback
2024-04-04 15:04:47 +02:00