* docs: update terraform example and doc for file generation
* docs: updated the documnettaion to include the help command with fields included
* Update pkg/cmd/grafana-cli/commands/commands.go
* docs: add help command
* RBAC: Add action to plugin includes
* Adding the feature toggle check
* Cue update
* Extract include access control to method
* Suggestion to prevent log when RBAC is disabled
Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
* Rename IsRBACReady to RequireRBACAction
Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
* Get pluginmeta mostly moved over to pkg/plugins/plugindef
* Remove dead func
* Fix up pfs, use sync.Once in plugindef
* Update to latest thema
* Chase Endec->Codec conversion in Thema
* Comments on slash header gen; use ToSlash
* Also generate JSON schema for plugindef
* Generate JSON Schema as well
* Fix slot loading from kindsys cue decls
* Remove unused vars
* skip generating plugin.schema.json for now
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
* initial implementation for quick add
* add new isCreateAction prop on NavModel
* adjust separator margin
* switch to primary button
* undo changes to plugin.json
* remove unused props from interface
* use a consistent dropdown overlay type
* memoize findCreateActions
* add prop description
* use a function so that menus are only rendered when the dropdown is open
* Component that can cache and extract variable dependencies
* Component that can cache and extract variable dependencies
* Updates
* Refactoring
* Lots of refactoring and iterations of supporting both re-rendering and query re-execution
* Updated SceneCanvasText
* Updated name of file
* Updated
* Refactoring a bit
* Added back getName
* Added comment
* minor fix
* Minor fix
* Merge fixes
* Merge fixes
* Some review fixes
* Updated comment
* Added forceRender function
* Add back fail on console log
* RBAC: Remove name from role registration
* Inline accesscontrol service
* test fix
* use fmt
Co-Authored-By: marefr <marcus.efraimsson@gmail.com>
Co-authored-by: marefr <marcus.efraimsson@gmail.com>
* fix: email and username trimming and invitation validation
* Trim leading and trailing whitespaces from email and username on signup
* Check whether the provided email address is the same as where the invitation sent
* Align tests
Co-authored-by: Mihaly Gyongyosi <mgyongyosi@users.noreply.github.com>
* add db migration at service start time
* make changes for the 3 db
* revert migrator
* fix feature toggle check
Co-authored-by: Serge Zaitsev <serge.zaitsev@grafana.com>
* Introduce a new feature flag for prometheus buffered client
* Use querydata client as default and put buffered client behind the feature flag
* Remove prometheusStreamingJSONParser feature flag as it is not needed anymore
* Update tests
* Fix unit tests
* Update feature flag description
* Nested Folders: Support getting of nested folder in folder service when feature flag is set
* Fix lint
* Fix some tests
* Fix ngalert test
* ngalert fix
* Fix API tests
* Fix some tests and lint
* Fix lint 2
* Fix library elements and panels
* Add access control to get folder
* Cleanup and minor test change
* Update thema to latest
* Deal with s/Library/*Runtime/
* Commit new, working results of codegen
* We like pointers now
* Always take runtime arg for NewBase()
* Sketchy handwavy pass at entity meta framework
* Little nibbles
* Update pkg/framework/coremodel/entityframework.cue
Co-authored-by: Artur Wierzbicki <wierzbicki.artur.94@gmail.com>
* Move file into new framework location
* Introduce loaders, Go code
* Complete rename to kind
* Flesh out framework, add svg/dashboard examples
* Cruft removal
* Remove generated kind go files from gitignore
* Refine maturity concept, add SlotKind
* Update embed and go deps
* Export PrefixWithGrafanaCUE
* Make the loader actually work, holy crap
* Many small tweaks to type.cue
* Add Apache 2 licensing exceptions for kinds
* Add new kinds dir, start of generator
* Roll back to earlier oapi-codegen
* Introduce new grafana-specific CUE loaders
* Introduce new tidy code generators framework
* Catch up kind framework with tinkering
* Add slices for the generators
* Add write/verify step to main generator
* Many renames
* Split up kind framework cue files
* Use kind.Decl within generated kinds
* Create kind.SomeDecl wrapper type to cache lineages
* Better names again
* Get one generated implemented, hopefully
* Copy dashboard schema into new kind.cue
* Small fixes to make the initial gen work
* Put svg kind in its new home
* Add generated Go dashboard type
* More renames and cleanups
* Add base kind registry and generator
* Stop blacklisting *_gen.go files
This is not the Go best practice, anyway. All we actually want to ignore
for enterprise is generated wire files.
* Change codegen output directories
pkg/kind -> pkg/kinds
pkg/registry/kindreg -> pkg/registry/corekind
* Rename pkg/framework/kind to pkg/kindsys
* Add core structured kind generator
* Add plural and machine names to kind spec
* Copy playlist over to kind system
* Consolidate kindsys files
* Add raw kind generator
* Update CODEOWNERS for kind framework
* Touch up comments a bit
* More docs tweaks
* Remove generated types to reduce noise for review
* Split each generator into its own file
* Rename Slot kind to Composable kind
* Add handwavy types for customkind loading
* Guard against init calls to framework loader
* First pass at doc on extending the kind system
* Improve attribute example in docs
* Fix wire imports
* Add basic TS types generator
* Fix composable kind category def
* No need for a separate file with generate directive
* Catch dashboard schema up
* Rename generator types to something saner and generic
* Make version configurable in ts/go generators
* Add CommonMeta to ease property access
* Add kindsys prop indicating whether lineage is group
* Put all kind categories back in a single file
* Finish with kindsys group props
* Refactor maturity progression per discussion
- Replace "committed" with "merged"
- All kindcats can use all maturity levels, at least for now
* Convert ts veneer index generator to modular system
* Move over to new jennywrites framework
* Strip down old coremodel generator
* Use public version of jennywrites
* Pull latest thema
* Commit generated Go types
* Add header injection postprocessor
* Move sdboyer/jennywrites to grafana/codejen
* Tweak header output
* Remove dashboard and playlist coremodels
* Fix up backend dashboards devenv test
* Fix TS import patterns to new gen filename
* Update internal imports, remove coremodel registry
* Fix compilation errors, wire generation
* Export and replace the prefix dropper
* More Go struct and field name changes
* Last name fixes, hopefully
* Fix lint errors
* Last lint error
Co-authored-by: Artur Wierzbicki <wierzbicki.artur.94@gmail.com>
* Remove URL-based alertmanagers from endpoint config
* WIP
* Add migration and alertmanagers from admin_configuration
* Empty comment removed
* set BasicAuth true when user is present in url
* Remove Alertmanagers from GET /admin_config payload
* Remove URL-based alertmanager configuration from UI
* Fix new uid generation in external alertmanagers migration
* Fix tests for URL-based external alertmanagers
* Fix API tests
* Add more tests, move migration code to separate file, and remove possible am duplicate urls
* Fix edge cases in migration
* Fix imports
* Remove useless fields and fix created_at/updated_at retrieval
Co-authored-by: George Robinson <george.robinson@grafana.com>
Co-authored-by: Konrad Lalik <konrad.lalik@grafana.com>
* feat(Connections): create sub-pages wrapped by `<Page>`
* feat(Connections): rename the Connections page and update routes
* feat(Connections): use new url for editing datasources
* refactor(Connections): remove unused tab components
* feat(Connections): update routes and nav titles
* tests: fix tests for Connections
* tests: fix typo in backend tests
* transfer DeleteFolder changes from larger PR
* finish some thingies
* add the simplest delete logics
* some intermedia steps
* fix tests
* add test
* fix some comments
Co-authored-by: yangkb09 <yangkb09@gmail.com>
* Refactor state and manager to not depend directly on image interface
* Move generic errors to models package
* Move NotAvailableImageService to state as its only references are in state tests
* Move NoopImageService to state package
* Move mock to state package
* Fix linter error
* Fix comment styling
* Fix a couple added references introduced by rebase
* Empty commit to kick build
* extract method processTick
* make processTick return scheduled rules
* move state manager tests to state manager
* update test
* move all tests into one file
* remove unused fields
* Plugins: CallResource: use canonical MIME headers when writing response
* Plugins: add tests for canonical mime headers and Set-Cookie filter
* Removed extra new line
* feat(loki-monaco-editor): update tests
* chore(loki): use unified datasource mock function in tests
* chore: enable monaco feature flag in tests
* feat(loki-monaco-editor): add test case for disabled feature
* feat(loki-monaco-editor): enable by default
* Revert "feat(loki-monaco-editor): enable by default"
This reverts commit 08904f94a707a4fa32aa1e7f3f0de377575a7636.
* feat(loki-monaco-editor): enable from registry
* feat(loki-monaco-editor): make feature flag frontend only
* Grafana Enterprise Packaging: Set to conflict with `grafana`, not replace
When `grafana` and `grafana-enterprise` are in the same RPM repository, grafana-enterprise takes precedence over Grafana
This is not what we want. Users should be able to install either OSS or Enterprise
* Set it only one way. It's how it's currently tested
This commit fixes an issue where mathexp.NoData would return an error
in ConditionsCmd (Classic Condition) instead of no data. It further
refactors the Execute method to make it easier to understand.
* chore: refactor CountDashboardsInFolder to use the more efficient Count() sql function
* feat(nested folders): Add CountAlertRulesInFolder to ngalert store
This commit adds CountAlertRulesInFolder and a new model for the CountAlertRulesQuery. It returns a count of alert rules associated with a given orgID and parent folder UID. (the namespace referenced inside alert rules is the parent folder).
I'm not sure where this belongs in the ngalert service, so that will come in a future commit.
* Folder: Add folder service implementation
* Add Move
* Add tests
* Add new servie method and adjust Update, Delete and Move
* Remove contains
* GetTree return children of depth one
* WIP
* add: better validation of conflict file
* add: better description of validation and ingest command
* add: check for at least one user to delete
* add: example in terraform to setup for conflicts
* Update pkg/cmd/grafana-cli/commands/conflict_user_command.go
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
* Add: print of conflict block for error
- adds conflict block to error output for validation of the file to
easier diagnose in the file
* fix: formatting of errors
* fix: info strings improvements
* add: default 0 to blocks to check for users
* fixed: tests
* test integration
* fix strings fmt
* set store in resolver
Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
Grafana's HTTPServer ensures that the Content-Type header is always set
in the response to a CallResource call, but when the status code is
204 No Content this shouldn't be done; the body should be empty and no
Content-Type header should be set.
We ran into this in the Grafana ML plugin where we were sending an empty
response with status 204, but the frontend client saw that the content
type was JSON and tried to parse it, resulting in an error that made it
to the JS console.
* delete all stale states in one lock
* do not use touched states to detect stale rely only on LastEvaluationTime maintained correctly
* fix tests to use correct eval time
* delete unused method
* chore: fix go lint issues
* feat(Routing): route standalone plugin pages to the `AppRoutePage`
* feat(plugin.json): introduce a new field called `isCorePage` for `includes`
* chore: add explanatory comments for types
* refactor(AppRootPage): receive the `pluginId` and `pluginSection` through the props
Now we are able to receive these as props as the pluginId is defined on navLinks
that are registered by plugins.
* chore: update teests for AppRootPage
* fix: remove rebase issue
* tests(applinks): add a test for checking isCorePage plugin page setting
* refactor(applinks): update tests to use FindById() and be more resilient to changes
* fix: Go lint issues
* refactor(routes): use cleaner types when working with plugin nav nodes
Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
* chore: fix linting issues
* t: remove `isCorePage` field from includes
Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
* Reduce piecemeal state fields
* Read data directly off state instead of rule
* Unify state and context into single struct
* Expose contextual information to layer above setNextState
* Work in terms of ContextualState and call historian in batches
* Call annotations service in batches
* Export format state and reason and remove workaround in unrelated test package
* Add new method to annotation service for batch inserting
* Fix loop variable aliasing bug caught by linter, didn't change behavior
* Incl timerange on annotation tests
* Insert one at a time if tags are present
* Point to rule from ContextualState rather than copy fields
* Build annotations and copy data prior to starting goroutine
* Rename to StateTransition
* Use new bulk-insert utility
* Remove rule from StateTransition and pass in directly to historian
* Simplify annotations logic since we have only one rule
* Fix logs and context, nilcheck, simplify method name
* Regenerate mock
* clean up and document integration test convention
* clarify integration test conventions
* clean up integration tests that don't follow convention
* mark testIntegration* functions as helpers to avoid confusion
* add: IsServiceAccount to SignedInUser and IsRealUser
* fix: linting error
* refactor: add function IsServiceAccountUser()
By adding the function IsServiceAccountUser() we use it to identify for
ServiceAccounts in the HasUniqueID() since caching is built up on having
a uniqueID, see comment: https://github.com/grafana/grafana/pull/58015#discussion_r1011361880
* feat(Navigation): add `pluginId` to NavLink and override sibling navlinks with the same URL
* test replacing page from plugin
* chore: fix go lint issues
* fix(NavLink): change `PluginId` to `PluginID`
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
* fix(NavLink): make the `PluginId` -> `PluginID` change everywhere
* chore(navModel.ts): update explanatory comment for `pluginId`
Co-authored-by: Miklós Tolnai <miklos.tolnai@grafana.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This PR splits the create and update paths for public dashboards and includes assorted refactors toward a proper REST API. Additionally, we removed the concept of a "public dashboard config" in favor of "public dashboard"
Co-authored-by: juanicabanas <juan.cabanas@grafana.com>
Co-authored-by: Ezequiel Victorero <ezequiel.victorero@grafana.com>
* Chore: Update grafana-plugin-sdk-go to v0.142.0
* Update tests and golden files for 207 status code
* Chore: Move update flag definition at the top in response_parser_test.go
* retrigger
Co-authored-by: Will Browne <will.browne@grafana.com>
* Add configuration options for `renderKey` lifetime
* Rename config key to `render_key_lifetime`
* Update conf/defaults.ini
Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
* Add `render_key_lifetime` to sample.ini
Co-authored-by: Joan López de la Franca Beltran <5459617+joanlopez@users.noreply.github.com>
* add: added a repeat migration w. fixed checks for permissions
* add: migration to migrations
* refactor: fix migration instead of making a new one
* fix: removed the old id
* fix: keep old name but change id
* add: migration for patched previous migration
* add: migration from missing file
* user essentials mob! 🔱
lastFile:pkg/services/libraryelements/writers.go
* user essentials mob! 🔱
lastFile:pkg/services/libraryelements/writers.go
* user essentials mob! 🔱
lastFile:pkg/services/libraryelements/writers.go
* user essentials mob! 🔱
lastFile:pkg/services/libraryelements/writers.go
* user essentials mob! 🔱
lastFile:pkg/services/libraryelements/database.go
* user essentials mob! 🔱
lastFile:pkg/services/libraryelements/writers.go
* user essentials mob! 🔱
lastFile:pkg/services/libraryelements/writers.go
* user essentials mob! 🔱
* support filterFolderUIDs in the frontend
* move common logic to a variable
* fixed FolderLibraryPanelsPage and improved unit test
* fix backend lint error
* fix formatting error
Co-authored-by: Joao Silva <joao.silva@grafana.com>
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
Co-authored-by: eledobleefe <laura.fernandez@grafana.com>
Co-authored-by: joshhunt <josh@trtr.co>
* make sql engine use pick log context for logs
* update tempo to get log context
* update opentsdb to use log context
* update es client to use log context
* feat(nested folders): add CountDashboardsInFolder
This commit adds a new method to the Dashboard service and stores: CountDashboardsInFolder. The command struct takes a folderUID, but the store implementation still depends on the parent folder ID. This is temporary; eventually we will replace all references to FolderIDs (associated with Dashboards) with folder UIDs.
There are some unfortunate additional test changes that were necessary after generating the service & store mocks; it looks like that hasn't been generated since the last change(s).
* more test updates
* don't forget the service test
* that didn't end up used, so bye for now
* agree to disagree with the linter
PublicDashboards: delete button added in public dashboard table in order to delete a public dashboard.
Co-authored-by: Jeff Levin <jeff@levinology.com>
* Oauth: change error type to a struct that unwraps into a social error
* Oauth: Handle empty role in error and fix unwrap
* Oauth: provide more informatio in error
* Oauth: return InvalidBasicRoleError
* Oauth: Fix tests
* Login: Remove casing
* Oath: Change to warning logs
* Add implementation for folder store methods
* Add Move implementation
* Add back comment and fix query
* Remove Move from store
* Adjust GetChildren
* Fix errutil error declaration and usage
* Add org id to get children query
* Add phlare datasource
* Rename
* Add parca
* Add self field to parca
* Make sure phlare works with add to dashboard flow
* Add profiling category and hide behind feature flag
* Update description and logos
* Update phlare icon
* Cleanup logging
* Clean up logging
* Fix for shift+enter
* onRunQuery to set label
* Update type naming
* Fix lint
* Fix test and quality issues
Co-authored-by: Joey Tawadrous <joey.tawadrous@grafana.com>
This PR imposes better naming conventions on public dashboards api
* rename api functions and remove use of _config_ noun
* fix tests
Co-authored-by: Ezequiel Victorero <ezequiel.victorero@grafana.com>
This PR fixes the naming of routes for public dashboards to be more accurate and descriptive.
Co-authored-by: Ezequiel Victorero <ezequiel.victorero@grafana.com>
* Add custom title to pushover contact point
* Update pkg/services/ngalert/notifier/channels/pushover.go
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Use simplejson
* Use more verbose variable names
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Add custom title to googlechet contact point
* Update pkg/services/ngalert/notifier/channels/googlechat.go
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Use simplejson
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Add custom title to discord contact point
* Update pkg/services/ngalert/notifier/channels/discord.go
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Use simplejson
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Add custom title to DingDing contact point
* Update pkg/services/ngalert/notifier/channels_config/available_channels.go
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Update pkg/services/ngalert/notifier/channels/dingding.go
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Add error checking before URL templating
* Remove comment
* Use simplejson
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Add title and description to VictorOps contact point
* Update pkg/services/ngalert/notifier/channels_config/available_channels.go
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Add description and details to Kafka notifier
* Fixed testing and add new logic testing
* Add proper description to kafka contact point UI
* Update pkg/services/ngalert/notifier/channels_config/available_channels.go
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Update pkg/services/ngalert/notifier/channels_config/available_channels.go
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
* Remove methods from sqlstore
* Remove commented out code
* Remove GetUserById from tests
* Adjust fake for get user profile
* Adjust test
* Adjust go mod files
* Try fix test
* Test adjustment
* Adjust test 2
* Remove commented out code
* create contextual log context provider
* use contextual provider in scheduler
* init logger in the package
* use context for log context
* use context in state manager
* make TimeRange interface and add relative range
* make Execute methods support the current time
* update resample to support relative time range
* update DSNode to support relative time range
* update query service to create queries with absolute time
* make alerting evaluator create relative time ranges
* feat: add new Folder table migration
Add a new folder table to support the Nested Folders feature.
https://github.com/grafana/grafana/issues/56880
* register nested folders feature flag (unused)
* feat: nested folder service (experiment)
This commit adds a NestedFolderSvc interface and stubbed out implementation as an alternative to the existing folder service. This is an experimental feature to try out different methods for backwards compatibility and parallelization, so that Grafana can continue to store folders in the existing (non-nested) manner while also using the new nested folder service.
Eventually the new service will (hopefully) become _the_ service, at which point the legacy service can be deprecated (or remain, with the new service methods replacing the original. whatever makes sense at the time).
* nested folders: don't run the new migration
This commit removes the nested folder migration from the list of active migrations so we can merge this branch and continue development without impacting Grafana instances built off main.
* refactor metrics request
* Update pkg/tsdb/cloudwatch/routes/dimension_keys_test.go
Co-authored-by: Shirley <4163034+fridgepoet@users.noreply.github.com>
* return metric struct value intead of pointer
* make it possible to test hard coded metrics service
* test all paths in route
* fix broken test
* fix one more broken test
* add integration test
Co-authored-by: Shirley <4163034+fridgepoet@users.noreply.github.com>
`pkg/web` triggers a panic when a http handler chain does not return any
response to the client.
This has been put in place, because it usually means a middleware along
the way did not call the next one.
In this specific case however, the handlers meant to return 200, but did
not do so explicitely, instead relying on the default behavior of `net/http`
* Revert "Revert "Prometheus: Type and flavor configuration (#56496)" (#57552)"
This reverts commit 2432ce619a.
* Adds new fields and documentation for Prometheus datasource configuration: prometheus type, and version
* Adding two new fields to the data JSON in the prometheus datasource configuration: prometheusType, and prometheusVersion.
* Version field will attempt to auto-detect via buildinfo API when prometheus Type is selected
* Chore: Delete unused mocks
* Add back used methods
* Add back used mocks 2
* Add back used mocks 3
* Add back used mocks 4
* Add back the alerting mocks
* Remove mock variables
* Add bacl needed mock var
* Touch up log statements, fix casing, add and normalize contexts
* Dedicated logger for dashboard resolver
* Avoid injecting logger to historian
* More minor log touch-ups
* Dedicated logger for state manager
* Use rule context in annotation creator
* Rename base logger and avoid redundant contextual loggers
* Add start time and end time parameters while querying tempo traces
* Added configurable time shift to query by trace id
* Test that the URL is formatted correctly
* Added test to check for time shift
* Improved label and tooltip of new time shift settings
Co-authored-by: André Pereira <adrapereira@gmail.com>
* Swap order of login fields
* Validate email field before validating the username field.
Co-authored-by: linoman <2051016+linoman@users.noreply.github.com>
* Plugins: Remove support for V1 manifests
* Plugins: Make proxy endpoints not leak sensitive HTTP headers
* Security: Fix do not forward login cookie in outgoing requests
(cherry picked from commit 4539c33fce)
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
* Audit logs in sender package
* Fix casing and touch up a few key names
* Avoid logging entire alert struct
* Log configuration ID being applied
* Revert change to errorf rather than log
* Tune levels further and remove some redundancies
* Adjust logger naming and standardize log context
* Adjust logger naming in router
* Move log and get rid of dead error handling code
* Add github release command to build/cmd
* Use go-github library and implement dry-run
* Make tag optional and default to metadata
* Fix minor bug with tag default
* Make some refactors to ease testing
* Add tests for publish github command
* Refactor publish github tests
* Refactor test helper function name
* Isolate local test
* remove Plugins and CloudIntegrations tab and add ConnectData tab
* ConnectData: add Search component and use it
* ConnectData: add DataSourcePluginList component
* add CardGrid component
* add CategoryHeader component
* ConnectData: restructure content
DataSourcePluginList is removed, because its responsibilities are
actually the same as ConnectData's responsibilities.
NoResults was added as a reusable component, and was moved out of
CardGrid, since there could be more CardGrid on one page, but only one
NoResults.
* fix spacer
* use LoadingPlaceholder
* CardGrid: add margin
* generalize CardGridProps
* move isLoading and error into CardGrid
We'd like CardGrid to be reusable, even multiple times within a page.
In this case, it's better UX if we show the loading or error states per
card grid, not for the whole page.
* ConnectData: fix NoResults condition
* fix and add meaningful tests
* fix indentation
* move isLoading and error back to ConnectData
* make `url` required for CardGrid items
* use new layered architecture in get dimension keys request
* go lint fixes
* pr feedback
* more pr feedback
* remove not used code
* refactor route middleware
* change signature
* add integration tests for the dimension keys route
* use request suffix instead of query
* use typed args also in frontend
* remove unused import
* harmonize naming
* fix merge conflict
* RBAC: Remove the access control evaluator fake
* API: Change to use access control implementation instead of mocks with
rbac disabled in tests
* Tests: Set cfg and access control defaults after applying options
* Tests: Rewrite team legacy access control tests
* Tests: Add helper function to create user with permissions
* Tests: set fake quota service as default
* Team: Add ExpectedTeamDTO and set in query result
* RBAC: Revert change
* RBAC: Add deprecation notice to mock
* Define EvaluationContext
* Refactor ConditionEval to use new context struct
* Refactor QueriesAndExpressionsEval to use EvaluationContext
* Remove dead field from AlertExecCtx
* Refactor Validate to use EvaluationContext
* Get rid of privately used AlertExecCtx
* Move EvaluationContext to new file and add helper
* Add builder pattern and bind rule info to context
* Extract header logic and add rule UID header
* Fix missing call
* chore: add alias for InitTestDB and Session
Adds an alias for the sqlstore InitTestDB and Session, and updates tests using these to reduce dependencies on the sqlstore.Store.
* next pass of removing sqlstore imports
* last little bit
* remove mockstore where possible
This change adds new functionality to the wecom alerting contact point. In addition to a webhook address, you can now send alerts to the wecom apiapp endpoint.
Based on https://github.com/grafana/grafana/discussions/55883
Signed-off-by: aimuz <mr.imuz@gmail.com>
* Alerting: Improve notification policies created during migration
Previously, migrated legacy alerts were connected to notification policies through
a `rule_uid` label in a 1:1 fashion. While this correctly mimicked pre-migration routing,
it didn't create a notification policy structure that is easy to view/modify. In addition,
having one policy per migrated alert is, in some ways, counter to the recommended approach of
Unified Alerting.
This change replaces `rule_uid`-based migrated notification policies with a private
label called `__contacts__`. This label stores a list of double quoted strings containing the names of
all contact points an AlertRule should route to (based on legacy notification channels). Finally,
one notification policy is created per contact point with each matching AlertRules via regex on this
`__contacts__` label.
The result is a simpler, clearer, and easier to modify notification policy structure, with the
added benefit that you can see which contact points an AlertRule is being routed to from the
AlertRule creation page.
* RBAC: Change the generate uid function to be deterministic so we can avoid collision
* RBAC: Use fmt.Errorf
* RBAC: Add comment
* RBAC: Export GenerateManagedRoleUID
* Theme: Inter font change with new line-height
* Add it behind feature toggle
* make buildVariant easier to read + enforce integer multiples of 2 (#56486)
* Minor update
* Update
Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
* Create caching dashboard resolver
* A couple tests for dashboard resolving
* Log warning on not found
* Additional polish + review nits
* Move to singleflight instead of a plain mutex
* Store errors instead of -1 in cache and use reflection when reading
* Address linter error
* One more linter error
* initial cut at refactor - need to run more tests
* fix unit tests
* change newly unused function to test helper
* create unit tests for parsing query requests that cover a range of cases
* add some comments
* rename function to avoid dev confusion
* add api route for validating a dashboard json
* add feature flag for showDashboardValidationWarnings
* tidy up
* comments and messages
* swagger specs
* fix typo
* more swagger
* tests!
* tidy test a little bit
* no more ioutil
* api will return different status code depending on validation error
* clean up
* handle 4xx errors
* remove console.log
* fix backend tests
* tidy up
* Swagger: Exclude alpha endpoints
Co-authored-by: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com>
* Elasticsearch: Fix calculation of trimEdges
When a value of trimEdges is set greater than 1 we need to drop both the
first and last sample of the data from the response.
* Elasticsearch: Fix reading trimEdges from the query settings
Currently the trimEdges property in the JSON panel is stored as a string
and not directly as a number.
This caused that the reading of the value failed in the go backend
because the simplejson.Int() method doesn't properly handle this case.
This failure when decoding the value goes unnoticed because of the early
return causing the trimEdges configuration to be ignored.
* Refactor castToInt to also return an error
Add a new test case that sets the `trimEdges` property as a quoted
number.
* Added nextPageToken prop
* Adding first and pageToken condition to while loop
* clean up
* revert gitignore
* fix go lint
* Added logic to builder too
* Removed pageSize - was for local testing
* gofmt
* extracted doRequest function
* extracted doRequest in query too
* Adressed filter comments
* Adressed query comments
* go fmt
* removed pageSize added for testing
* go fmt again
This PR adds an audit table for public dashboards allowing a user to view all public dashboards on an instance of grafana. The public dashboards team is working on a proposal for adding RBAC support to the audit table for 9.3
Co-authored-by: juanicabanas <juan.cabanas@grafana.com>
* LDAP: Add skip_org_role_sync option
* Document the new config option
* Nit on docs
* Update docs/sources/setup-grafana/configure-security/configure-authentication/ldap.md
Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
* Docs suggestions
Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
Co-authored-by: Jguer <joao.guerreiro@grafana.com>
* Add test, Fix disabled user when no role
Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
Co-authored-by: Jguer <joao.guerreiro@grafana.com>
When testing a rule within the legacy alerting the `timeMs` field could
sometimes show negative (and/or wrongly calculated) durations. This happens if the alert evaluation crosses a second boundary. This change uses the full timestamp to compute the eval duration.
* Chore: move folder service interface into a separate package
* copy implementation into a standalone package
* move implementation and tests to the new folder package
* remove leftovers from wire
* add test doubles for folder service
* fix tests in library panels/elements
* fix provideservice in ngalert
We have received a lot of feedback regarding the ValueString in alert notifications. Perhaps one of the most frequent complaints about ValueString is that it is difficult to read because it contains a lot of information, and the information is shown as a JSON-like string. Users have often asked how it can be templated and the answer is that it can't.
Until now users have been able to add custom annotations to their alert rules which contains values via the $values variable added in previous versions of Grafana. However, these custom annotations must be added for each of the user's alert rule, instead of once in a template that all of their alerts can be notified via.
This commit adds then the much requested feature to support values in notification templates. Users can then create a single template that prints the annotations, labels and values of their alerts in a format of their choice!
* Flamegraph
* Updated flame graph width/height values
* Fix top table rendering issue
* Add feature toggle for flamegraph in explore
* Update tests
* Hide flamegraph from dash panel viz list if feature toggle not enabled
* Show table if no flameGraphFrames
* Add flame graph to testdata ds
* Minor improvement
This commit fixes a bug where changing the Folder or Rule Group of an existing rule returns the following error in PostgreSQL "pq: missing FROM-clause for table a"
grafana.com/grafana/prometheus-alertmanager has been updated to a
version that fixes some bugs upstream. This change just updates that
dependency and a few shared ones.
This PR refactors how we add the orgId to the context on a public dashboard paths. We also split out accessToken handling into its own package and rework status code for "RequiresValidAccessToken". We will be modeling all endpoints to use these status codes going forward. Additionally, it includes a scaffold for better middleware testing and refactors existing tests to table drive tests.
* remove ResetAllStates because it's not used
* refactor cache to accept logs, metrics and url as method args
* update manager Warm method to set the entire state at once
* remove unused reset method
* introduce ruleStates
* change getOrCreate to belong to ruleStates
* update Get to not return error