* simplify some dependency injection in macaron
* remove unused internal server error handler from macaron
* remove internal server error handler from the router
* remove unused combo router api
* remove unused parts of the macaron router
Skipping TestDevenvDashboardValidity test for now to resolve broken
test-backend step in main/branches. Did also run scripts/stripnulls.sh
hence the devenv dashboard changes.
* Add short url validation
Path should not contain string ../
* Update pkg/api/short_url.go
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Fixes#30144
Co-authored-by: dsotirakis <sotirakis.dim@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
Co-authored-by: spinillos <selenepinillos@gmail.com>
Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: Leonard Gram <leo@xlson.com>
* Relocate dashboard scuemata to grafana-schema
* Update assorted tests, vars with dashboard path
* Remove crufty commented var
* Not sure...why that failed
* Remove prefix from base dashboard path var
* Move cue/ui remnants into grafana-schema
* Update import paths in plugin models
* Remove mudball, add package statements
* Remove cuegen.sh
Wooooo we ain't got no codegen
* Revert "Remove mudball, add package statements"
This reverts commit 9bed3098f1.
* Tidy up all the cue files
* Move dashboard scuemata into scuemata/ subdir
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
* Provide correct link for AGPL license
* Change LicenseURL to point go Grafana OSS page
* Keep utm_source query parameter
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Introduces org-level isolation for the Alertmanager and its components.
Silences, Alerts and Contact points are not separated by org and are not shared between them.
Co-authored with @davidmparrott and @papagian
* add a more flexible way to create permissions
* update interface for accesscontrol to use new eval interface
* use new eval interface
* update middleware to use new eval interface
* remove evaluator function and move metrics to service
* add tests for accesscontrol middleware
* Remove failed function from interface and update inejct to create a new
evaluator
* Change name
* Support Several sopes for a permission
* use evaluator and update fakeAccessControl
* Implement String that will return string representation of permissions
for an evaluator
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
* Make the evaluator prefix match only
* Handle empty scopes
* Bump version of settings read role
Co-authored-by: Karl Persson <kalle.persson@grafana.com>
* Add check before delete org
* Fix comment
* Simpify check if signed in user belongs to the org
* Add check on login if user has and existing org
change error code to 400, when org can not be deleted
* Roll back last commit, regarding an different issue
Even without the ability to control the sort order or to filter, this notably improves usability for long lists of notification channels.
Partially fixes#20067.
* Group alertmangaer alerts by custom grouping
* Filter am groups
* Style filter components
* Style filter bar and add clear functionality
* rename components to alert group
* use query params for group filters
* filter style improvements
* add tests for group by
* Add grouping banner to better highlight groupings
* clean up hook logic
* Convert tag values returned as numbers to string
This is a bug in Graphite <= 1.1.7. Since 1.1.8 all values are converted to strings.
* Simplify type conversions
* Fix linting errors
This commit adds contact point testing to ngalerts via a new API
endpoint. This endpoint accepts JSON containing a list of
receiver configurations which are validated and then tested
with a notification for a test alert. The endpoint returns JSON
for each receiver with a status and error message. It accepts
a configurable timeout via the Request-Timeout header (in seconds)
up to a maximum of 30 seconds.
* Strip nulls (again)
* Add stripnulls script
* Add transformations field
* Close FieldConfig struct; proper plugin validating
* s/graph/viz/ field in histogram dashboard
* Use ui.GraphFieldConfig in histogram model
* Add models for stat, gauge, barguage panel plugins
Also toss necessary shared types into cue/ui/gen.cue, with TODOs to move
them appropriately later.
* Add required license headers
* Heap of updates to cue UI components
* Fix barchart types and one old devenv input
* Use the GraphFieldConfig directly for timeseries
* Add models.cue for a few panel plugins
Barchart, state-timeline, and status-history
* Enable the test validating all devenv dashboards!!
* Fix effects of not checking after making comments
* Update packages/grafana-ui/src/options/models.gen.ts
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
* Realign and unalign cue with ts types
* Update devenv test to sniff for null errors
Best option we have right now for helping people to know they need to
strip nulls from devenv dashboards.
* Add speculative default for barchart stacking
* Fixup some dated devenv dashboards
timeline-modes needed to be regenerated with the appropriate tooltip
values included, per typing requirements, and timeline-demo needed to
have the `mode` field removed, as it is not intended to be persisted.
* Add necessary missing options for various panels
* Regenerate devenv dashboards
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
* Add input to specify min step
* Add stepInterval to as input to component
* Add onBlur to Input component
* Loki: add functionality for min step
* Loki: change name on props to step to make it more clear
* Loki: add resolution as a query option
* Loki: Add min,max,exact as step options
* Loki: add functionality for different step modes
* Loki: fix bug where step function isn't working
* Loki: fix bug where exact step isn't working
* Loki: change width of step input field
* Loki: add tests for adjustInterval function
* Loki: add check for max step oprio to make sure it's not below the safe interval
* Loki: fix bug with some tests
* Loki: fix bug with tests
* Explore: add tooltip to loki step function
* Loki: remove resolution as a logs option
* Loki: update snapshots
* Fix failing tests
* Loki: add select component for choosing resolution
* Loki: add functionality for calculating correct interval with resolution applied
* Loki: remove functionality for step mode
* Loki: remove tests for step mode
* Loki: add tooltip to line limit and resolution
* Loki: add backend support for resolution
* Loki: fixed backend bug where resolution was undefined
* Loki: add check for resolution
* Add deep link in ARG
* add soverigh clouds
* add query to Azure portal link
* move deep link to backend
* cloud specific to ARG
* Add unit test
* fix lint
* fix escape issue
* use constant & fix test
* fix constant & use pathEscape
* use cmp.Equal for test
* Alerting: Expose discovered and dropped Alertmanagers
Exposes the API for discovered and dropped Alertmanagers.
* make admin config poll interval configurable
* update after rebase
* wordsmith
* More wordsmithing
* change name of the config
* settings package too
* Alerting: modify table and accessors to limit org access appropriately
* Update migration to create multiple Alertmanager configs
* Apply suggestions from code review
Co-authored-by: gotjosh <josue@grafana.com>
* replace mg.ClearMigrationEntry()
mg.ClearMigrationEntry() would create a new session.
This commit introduces a new migration for clearing an entry from migration log for replacing mg.ClearMigrationEntry() so that all dashboard alert migration operations will run inside the same transaction.
It adds also `SkipMigrationLog()` in Migrator interface for skipping adding an entry in the migration_log.
Co-authored-by: gotjosh <josue@grafana.com>
* Alerting: Send alerts to external Alertmanager(s)
Within this PR we're adding support for registering or unregistering
sending to a set of external alertmanagers. A few of the things that are
going are:
- Introduce a new table to hold "admin" (either org or global)
configuration we can change at runtime.
- A new periodic check that polls for this configuration and adjusts the
"senders" accordingly.
- Introduces a new concept of "senders" that are responsible for
shipping the alerts to the external Alertmanager(s). In a nutshell,
this is the Prometheus notifier (the one in charge of sending the alert)
mapped to a multi-tenant map.
There are a few code movements here and there but those are minor, I
tried to keep things intact as much as possible so that we could have an
easier diff.
* Pass Access info to datasourceInstance
* Update packages/grafana-data/src/types/datasource.ts
Co-authored-by: Giordano Ricci <me@giordanoricci.com>
* Type access as direct | proxy
* Fix tests where mocking datasourceInstance, include access
* Pass access to data source instance mocks
* Update comment
* Pass access to data source instance mocks
Co-authored-by: Giordano Ricci <me@giordanoricci.com>
* Refactor loki to use SDK contracts
* Register with service name
* Initialize interval calculator
* Return always created result
* Use go library instead of simplejson
* Update pkg/tsdb/loki/loki.go
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
* Remove newline
* Merge with main
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
* Add select component for choosing step option
* Add onStepChange
* Add functionality for max step
* Rename minInterval to stepInterval to describe min, max and exact step interval
* Change select option from standard to exact
* Add new type StepType for better type safety
* Add tests for adjustInterval
* Add functionality and tests for exact step option
* Prometheus: Spell out min and max in select component
* Prometheus: Change width of step select component and add placeholder
* Prometheus: Adjust for the factor in exact step
* Prometheus: Update tooltip of step lable to include max and exact options and add padding to select component to give it some breathing room from other components
* Update snapshot for step tooltip
* Prometheus: make tooltip more informative
* Prometheus: add tooltip to interval input element
* Prometheus: extract default step option
* Prometheus: update snapshot for PromQueryEditor
* Prometheus: change step labels to uppercase
* Prometheus: define a default step option
* Prometheus: use default step option in both ui component and logic
* Prometheus: update snapshot for PromQueryEditor
* Prometheus: refactor datasource.ts for better readability
* Prometheus: change tool tip for step
* Prometheus: update snapshots
* Prometheus: add correct styling
* Prometheus: update snapshots
* Prometheus change variable name to something less superfluous
* Prometheus: refactor
* Prometheus: add new test for adjustInterval
* Docs: Update docummentation on the step parameter for prometheus
* Prometheus: make step input field smaller and change placeholder text to 15s
* Prometheus: update snapshots
* Prometheus: Make stepMode uniform in all places in the code
* Adjust step based on stepMode
* Adjust comment
* Check if we have queryInterval
* Refactor, add safe interval
* Fix merge resolutions
* Fix tests and add tests
* Update snapshot
* Update docs/sources/datasources/prometheus.md
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
* Update docs/sources/datasources/prometheus.md
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
* Update docs/sources/datasources/prometheus.md
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
* Update docs/sources/datasources/prometheus.md
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
* Update docs/sources/datasources/prometheus.md
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
* Update docs/sources/datasources/prometheus.md
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
* Update docs/sources/datasources/prometheus.md
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
* Implement calculation with intervalMode in calculator.go
* Update tests, add calculate safe interval method
* Replace panic with error
* Update pkg/tsdb/interval/interval_test.go
Co-authored-by: idafurjes <36131195+idafurjes@users.noreply.github.com>
* Update pkg/tsdb/calculator_test.go
Co-authored-by: idafurjes <36131195+idafurjes@users.noreply.github.com>
* Impotrt require
* Remove lint errors
Co-authored-by: Olof Bourghardt <ob655088@gmail.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
Co-authored-by: idafurjes <36131195+idafurjes@users.noreply.github.com>
* simplify toggle + add link to server admin
* feat(catalog): org admins can configure plugin apps, cannot install/uninstall plugins
* fix(catalog): dont show buttons if user doesn't have install permissions
* feat(catalog): cater for accessing catalog via /plugins and /admin/plugins
* feat(catalog): use location for list links and match.url to define breadcrumb links
* test(catalog): mock isGrafanaAdmin for PluginDetails tests
* test(catalog): preserve default bootdata in PluginDetails mock
* refactor(catalog): move orgAdmin check out of state and make easier to reason with
Co-authored-by: Will Browne <will.browne@grafana.com>
* AccessControl: Implement a way to register fixed roles
* Add context to register func
* Use FixedRoleGrantsMap instead of FixedRoleGrants
* Removed FixedRoles map to sync.map
* Wrote test for accesscontrol and provisioning
* Use mutexes+map instead of sync maps
* Create a sync map struct out of a Map and a Mutex
* Create a sync map struct for grants as well
* Validate builtin roles
* Make validation public to access control
* Handle errors consistently with what seeder does
* Keep errors consistant amongst accesscontrol impl
* Handle registration error
* Reverse the registration direction thanks to a RoleRegistrant interface
* Removed sync map in favor for simple maps since registration now happens during init
* Work on the Registrant interface
* Remove the Register Role from the interface to have services returning their registrations instead
* Adding context to RegisterRegistrantsRoles and update descriptions
* little bit of cosmetics
* Making sure provisioning is ran after role registration
* test for role registration
* Change the accesscontrol interface to use a variadic
* check if accesscontrol is enabled
* Add a new test for RegisterFixedRoles and fix assign which was buggy
* Moved RegistrationList def to roles.go
* Change provisioning role's description
* Better comment on RegisterFixedRoles
* Correct comment on ValidateFixedRole
* Simplify helper func to removeRoleHelper
* Add log to saveFixedRole and assignFixedRole
Co-authored-by: Vardan Torosyan <vardants@gmail.com>
Co-authored-by: Jeremy Price <Jeremy.price@grafana.com>
* wip
* Auth Info: refactored out into it's own service
* Auth: adds extension point where users are being mapped
* Update pkg/services/login/authinfoservice/service.go
Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com>
* Update pkg/services/login/authinfoservice/service.go
Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com>
* Auth: simplified code
* moved most authinfo stuff to its own package
* added back code
* linter
* simplified
Co-authored-by: Joan López de la Franca Beltran <joanjan14@gmail.com>
* Refactor resample logic
* Adjust test to have one more timestamp out of range
* adjust test + ensure filling
* revert flag flip
* Undo logic - should be timeseries only
* change data calculation based on previous interval
* fix the logics
* fix typo
* fix resample start time, to reuse what sql api returned
* calculate the start point with from truncate by interval
Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
Co-authored-by: Ying WANG <ying.wang@grafana.com>
* Alerting: Refactor `Run` of the scheduler
A bit of a refactor to make the diff easier to read for supporting
external Alertmanagers.
We'll introduce another routine that checks the database for
configuration and spawns other routines accordingly.
* Block the wait.
* Fix test
* initial attempt at automatic removal of stale states
* test case, need espected states
* finish unit test
* PR feedback
* still multiply by time.second
* pr feedback
* Azure middleware in HttpClientProxy
* Azure authentication under feature flag
* Minor fixes
* Add prefixes to not clash with JsonData
* Return error if JsonData cannot be parsed
* Return original string if URL invalid
* Tests for datasource_cache