This commit better defines how we set states in resultNormal,
resultAlerting, resultError and resultNoData. It changes the existing
code to call methods such as SetAlerting, SetPending, SetNormal,
SetError and NoData instead of assigning values to each individual field
whenever the state is changed. This should make it easier to understand
what fields should be set for which states and avoid cases where states are
missing, or have additional unexpected fields.
Before this change, the alerting provisioning system incorrectly used
the QuotaTarget to check if alerting's request quota had been reached.
The quota service requires the QuotaTargetSrv, which is what's
registered with the service at startup time. This is leading to errors
in the provisioning system.
* block move operation that could introduce more than 8 level of depth, forbid circular reference
* move getHeight to store, mock store in service
* fix linter
* Auth: Session cache [v9.2.x] (#59907)
* add cache wrapper
only cache token if not to rotate
Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
anticipate next rotation
Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
(cherry picked from commit 07a4b2343d)
* FeatureToggle: for storing sessions in a Remote Cache
Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
(cherry picked from commit b8a8c15148)
* use feature flag for session cache
* ensure ttl is minimum 1 second
Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
* ensure 2 ttl window to prevent caching of tokens near rotation
Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
* fix description of toggle
Co-authored-by: gamab <gabi.mabs@gmail.com>
Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
Co-authored-by: Kalle Persson <kalle.persson@grafana.com>
Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
(cherry picked from commit 2919588a82)
* fix broken quota test
* don't remove grafana-server and grafana-cli binaries from /usr/share/grafana/bin in deb and rpm packages
* don't add config overrides in /usr/sbin/grafana-server
* update pagerduty and opsgenie to deserialize settings using standard JSON library
* update pagerduty truncation to use a function from Alertamanger package
* update opsgenie to use payload model (same as in Alertmanager)
* Elasticsearch: Fix removing of empty settings from query in backend implementation
* Update
* Update
* Update pkg/tsdb/elasticsearch/time_series_query.go
Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
Co-authored-by: Gábor Farkas <gabor.farkas@gmail.com>
* RBAC: add viewer grand if dspermissions enforcement is not enabled
* RBAC: Change permissions based on role prefix
* RBAC: Add option to for permission service to add a license middleware
* RBAC: Remove actions from query struct
This commit makes a number of changes to how images work in Slack
notifications.
It adds support for uploading images to Slack via the files.upload
API when the contact point has a token. Images are no longer linked
via a URL if a token is present.
Each image uploaded to Slack is posted as a reply to the original
notification. Up to maxImagesPerThreadTs images can be posted as
replies before a final message is sent with:
There are no images than can be shown here. To see the panels for
all firing and resolved alerts please check Grafana
Incoming Webhooks cannot upload files via files.upload and so webhooks
require the image to be uploaded to cloud storage and linked via URL.
* cleanup cloudwatch.go
* streamline interface naming
* use utility func
* rename test utils file
* move util function to where they are used
* move dtos to models
* split integration tests from the rest
* Update pkg/tsdb/cloudwatch/cloudwatch.go
Co-authored-by: Isabella Siu <Isabella.siu@grafana.com>
* refactor error codes aggregation
* move error messages to models
Co-authored-by: Isabella Siu <Isabella.siu@grafana.com>
* wip
* wip
* almost there..
* wip - change so it can run.
* treelist is working.
* support CODEGEN_VERIFY env variable
* use log.fatal
* comment out old PluginTreeList code generation
* cleanup
* rename corelist package files
* fix makefile
* move pkg/codegen/pluggen.go to pkg/plugins/codegen
* copy and refactor files to pkg/plugins/codegen
* use pkg/plugins/codegen instead of pkg/codegen for core plugins code gen
* remove unneeded files
* remove unused code to resolve linting errors
* adapters first hack
* added flattener
* add back ignore build tags to go generate file
* cleaned up the code a bit.
* seems to work, needs to do some refactoring of the GoTypesJenns and TSTypesJenny.
* one more step, going to get upstream changes in this branch.
* working but need to run import tmpl in jenny_schemapath to have the proper imports.
* added header to generated files.
* added missing jenny.
* preventing plugins with multiple decls/schemas to insert multiple lines in corelist.
* fixed so we use Slot type from kindsys to detect if its group.
* adding a go jenny that only runs if the plugin has a backend.
* added version object to generated ts.
* generating the ts types with the same output as prior to this refactoring.
* removed code that is replaced by the jenny pattern.
* removed the go code that isn't used anymore.
* removed some more unused code and renamed pluggen to util_ts
* fixed linting issue.
* removed unused vars.
* use a jenny list postprocessor for header injection
* moved decl and decl_parser to pfs.
* removed the pre-pended header in the gotypes jenny since it is done in the postprocess.
* moved decl to pfs.
* removed unused template.
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
* make create call consistent with update and delete
* send multiple targets to graphite and correlate the responses with the requests
* make create call consistent with update and delete
* send multiple targets to graphite and correlate the responses with the requests
* Revert "make create call consistent with update and delete"
This reverts commit 26b6463bd6.
* refactor query -> target parsing and fix unit tests
* add additional validations and more unit tests
* change error statement to warn
Adding support for backend plugin client middlewares. This allows headers in outgoing
backend plugin and HTTP requests to be modified using client middlewares.
The following client middlewares added:
Forward cookies: Will forward incoming HTTP request Cookies to outgoing plugins.Client
and HTTP requests if the datasource has enabled forwarding of cookies (keepCookies).
Forward OAuth token: Will set OAuth token headers on outgoing plugins.Client and HTTP
requests if the datasource has enabled Forward OAuth Identity (oauthPassThru).
Clear auth headers: Will clear any outgoing HTTP headers that was part of the incoming
HTTP request and used when authenticating to Grafana.
The current suggested way to register client middlewares is to have a separate package,
pluginsintegration, responsible for bootstrap/instantiate the backend plugin client with
middlewares and/or longer term bootstrap/instantiate plugin management.
Fixes#54135
Related to #47734
Related to #57870
Related to #41623
Related to #57065
The GrafanaComURL setting is currently used in two places:
- the /api/gnet endpoint, which proxies all requests to the URL
configured in GrafanaComURL
- OAuth logins using grafana.com, where the auth URL, token URL and
redirect URL are all configured to use the GrafanaComURL.
This has worked fine until now because almost all Grafana instances have
just used the default value, https://grafana.com. However, we now have a
few different grafana.com's, some of which are behind IAP. The IAP
causes the /api/gnet proxy to fail because the required cookies are not
present in the request (how could they be?). Setting the
[grafana_net.url] setting to an internal-only URL improves the situation
slightly - the proxy works again just fine - but breaks any OAuth logins
using grafana.com, because the user must be redirected to a publicly
accessible URL.
This commit adds an additional setting, `[grafana_com.api_url]`,
which can be used to tell Grafana to use the new API URL when proxying
requests to the grafana.com API, while still using the existing
`GrafanaComURL` setting for other things.
The setting will fall back to the GrafanaComURL setting + "/api" if unset.
* Add Team kind
* Minor changes
* Use ToMedatata annotation
Co-authored-by: sam boyer <sdboyer@grafana.com>
* Use ToMedatata annotation
Co-authored-by: sam boyer <sdboyer@grafana.com>
* Use ToMedatata annotation
Co-authored-by: sam boyer <sdboyer@grafana.com>
* Use ToMedatata annotation
Co-authored-by: sam boyer <sdboyer@grafana.com>
* Update comments
* Add created and updated fields
* Make orgId required
* Use int64 for datetime
Co-authored-by: sam boyer <sdboyer@grafana.com>
* Fix deleting subfolder
It used to fail with beause of missing signed in user
* Add logging
* fixup
* Fail request if deleting nested folder has failed
Before we only used to log the error
* Fix failing test
During failed nested folder creation
call the dashboard store deletion instead of the service one.
* move original stats service into a separate package
* add stats service to wire
* move GetAdminStats
* switch to using stats.Service
* add missing package
* fix api tests
* Remove DeleteUser from sqlstore
* Use Delete instead of DeleteUser
* Remove unused method
* Remove DeleteUserSession from sqlstore
* Add fake for DeleteUseraccessControl
* Use user service, add fakes to tests
* Add comments to sqlstore
* Correct typo
* Add quota service initialisation
* Add config to acimpl initialisation
* Add routing to initialisation
* Making user provideStore private
* Use InTransaction instead of session
* Add cfg to userimpl
* Fix lint
* Make ProvideStore public again - enterprise tests
* Fix back ProvideStore to public
* Wrap merge user in transaction
* Delete DeleteUserAccessControl use DeleteUSerPermissions instead
* Add feature mgmt into acimpl
* DeleteUserAccessControl from ac database
* Remove case insensitive clause
* RBAC: Add an endpoint to see all user permissions
Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
* Fix mock
* Add feature flag
* Fix merging
* Return normal permissions instead of simplified ones
* Fix test
* Fix tests
* Fix tests
* Create benchtests
* Split function to get basic roles
* Comments
* Reorg
* Add two more tests to the bench
* bench comment
* Re-ran the test
* Rename GetUsersPermissions to SearchUsersPermissions and prepare search options
* Remove from model unused struct
* Start adding option to get permissions by Action+Scope
* Wrong import
* Action and Scope
* slightly tweak users permissions actionPrefix query param validation logic
* Fix xor check
* Lint
* Account for suggeston
Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
* Add search
* Remove comment on global scope
* use union all and update test to make it run on all dbs
* Fix MySQL needs a space
* Account for suggestion.
Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
Co-authored-by: Joey Orlando <joey.orlando@grafana.com>
Co-authored-by: Joey Orlando <joseph.t.orlando@gmail.com>
Co-authored-by: ievaVasiljeva <ieva.vasiljeva@grafana.com>
* feat(plugins-catalog): only allow admins to access plugins catalog routes
* add backend check
* fix(plugins-catalog): update route role access to include server admins
Co-authored-by: Will Browne <will.browne@grafana.com>
* navtree.go: update Data sources title and subtitle
* DataSourceList: move add button to header
* DataSourcesList: add buttons to items
The action buttons are added inside `<Card.Tags>` so that they end up at
the right end of the card, as it was designed.
The "Build a Dashboard" button's functionality is not defined yet.
* DataSourcesListHeader: add sort picker
* fix css
* tests: look for the updated "Add new data source" text
* tests: use an async test method to verify component updates are wrapped in an act()
* update e2e selector for add data source button
* fix DataSourceList{,Page} tests
* add comment for en dash character
* simplify sorting
* add link to Build a Dashboard button
* fix test
* test build a dashboard and explore buttons
* test sorting data source elements
* DataSourceAddButton: hide button when user has no permission
* PageActionBar: remove unneeded '?'
* DataSourcesList: hide explore button if user has no permission
* DataSourcesListPage.test: make setup prop explicit
* DataSourcesList: use theme.spacing
* datasources: assure explore url includes appSubUrl
* fix tests and add test case for missing permissions
Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
* streamline and sync dockerfiles
* improve go dependency cacheability
* unify alpine and ubuntu Dockerfiles
* include glibc support in locally-built alpine images
* recover from panic inside mixed ds query loop
* remove accidental commit
* add messages from panics and errors to the query response
* refactor based on PR comments
* quick update to unit test to verify mixed errors and successes
* reduce concurrency limit
* Lattice: Point to private prerelease of aws-sdk-go (#515)
* point to private prerelease of aws-sdk-go
* fix build issue
* Lattice: Adding a feature toggle (#549)
* Adding a feature toggle for lattice
* Change name of feature toggle
* Lattice: List accounts (#543)
* Separate layers
* Introduce testify/mock library
Co-authored-by: Shirley Leu <4163034+fridgepoet@users.noreply.github.com>
* point to version that includes metric api changes (#574)
* add accounts component (#575)
* Test refactor: remove unneeded clientFactoryMock (#581)
* Lattice: Add monitoring badge (#576)
* add monitoring badge
* fix tests
* solve conflict
* Lattice: Add dynamic label for account display name (#579)
* Build: Automatically sync lattice-main with OSS
* Lattice: Point to private prerelease of aws-sdk-go (#515)
* point to private prerelease of aws-sdk-go
* fix build issue
* Lattice: Adding a feature toggle (#549)
* Adding a feature toggle for lattice
* Change name of feature toggle
* Lattice: List accounts (#543)
* Separate layers
* Introduce testify/mock library
Co-authored-by: Shirley Leu <4163034+fridgepoet@users.noreply.github.com>
* point to version that includes metric api changes (#574)
* add accounts component (#575)
* Test refactor: remove unneeded clientFactoryMock (#581)
* Lattice: Add monitoring badge (#576)
* add monitoring badge
* fix tests
* solve conflict
* add account label
Co-authored-by: Shirley Leu <4163034+fridgepoet@users.noreply.github.com>
Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
* fix import
* solve merge related problem
* add account info (#608)
* add back namespaces handler
* Lattice: Parse account id and return it to frontend (#609)
* parse account id and return to frontend
* fix route test
* only show badge when feature toggle is enabled (#615)
* Lattice: Refactor resource response type and return account (#613)
* refactor resource response type
* remove not used file.
* go lint
* fix tests
* remove commented code
* Lattice: Use account as input when listing metric names and dimensions (#611)
* use account in resource requests
* add account to response
* revert accountInfo to accountId
* PR feedback
* unit test account in list metrics response
* remove not used asserts
* don't assert on response that is not relevant to the test
* removed dupe test
* pr feedback
* rename request package (#626)
* Lattice: Move account component and add tooltip (#630)
* move accounts component to the top of metric stat editor
* add tooltip
* CloudWatch: add account to GetMetricData queries (#627)
* Add AccountId to metric stat query
* Lattice: Account variable support (#625)
* add variable support in accounts component
* add account variable query type
* update variables
* interpolate variable before its sent to backend
* handle variable change in hooks
* remove not used import
* Update public/app/plugins/datasource/cloudwatch/components/Account.tsx
Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
* Update public/app/plugins/datasource/cloudwatch/hooks.ts
Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
* add one more unit test
Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
* cleanup (#629)
* Set account Id according to crossAccountQuerying feature flag in backend (#632)
* CloudWatch: Change spelling of feature-toggle (#634)
* Lattice Logs (#631)
* Lattice Logs
* Fixes after CR
* Lattice: Bug: fix dimension keys request (#644)
* fix dimension keys
* fix lint
* more lint
* CloudWatch: Add tests for QueryData with AccountId (#637)
* Update from breaking change (#645)
* Update from breaking change
* Remove extra interface and methods
Co-authored-by: Shirley Leu <4163034+fridgepoet@users.noreply.github.com>
* CloudWatch: Add business logic layer for getting log groups (#642)
Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
* Lattice: Fix - unset account id in region change handler (#646)
* move reset of account to region change handler
* fix broken test
* Lattice: Add account id to metric stat query deep link (#656)
add account id to metric stat link
* CloudWatch: Add new log groups handler for cross-account querying (#643)
* Lattice: Add feature tracking (#660)
* add tracking for account id prescense in metrics query
* also check feature toggle
* fix broken test
* CloudWatch: Add route for DescribeLogGroups for cross-account querying (#647)
Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>
* Lattice: Handle account id default value (#662)
* make sure right type is returned
* set right default values
* Suggestions to lattice changes (#663)
* Change ListMetricsWithPageLimit response to slice of non-pointers
* Change GetAccountsForCurrentUserOrRole response to be not pointer
* Clean test Cleanup calls in test
* Remove CloudWatchAPI as part of mock
* Resolve conflicts
* Add Latest SDK (#672)
* add tooltip (#674)
* Docs: Add documentation for CloudWatch cross account querying (#676)
* wip docs
* change wordings
* add sections about metrics and logs
* change from monitoring to observability
* Update docs/sources/datasources/aws-cloudwatch/_index.md
Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
* Update docs/sources/datasources/aws-cloudwatch/query-editor/index.md
Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>
* Update docs/sources/datasources/aws-cloudwatch/query-editor/index.md
Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>
* Update docs/sources/datasources/aws-cloudwatch/query-editor/index.md
Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
* Update docs/sources/datasources/aws-cloudwatch/query-editor/index.md
Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>
* apply pr feedback
* fix file name
* more pr feedback
* pr feedback
Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>
* use latest version of the aws-sdk-go
* Fix tests' mock response type
* Remove change in Azure Monitor
Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
Co-authored-by: Shirley Leu <4163034+fridgepoet@users.noreply.github.com>
Co-authored-by: Fiona Artiaga <89225282+GrafanaWriter@users.noreply.github.com>
* remove legacy createorg from org service
* remove another createorg from orgimpl
* remove createorg from api pref tests
* remove createorg from api org tests
* fix tests
* remove createorg from annotations test
* remove createorg from team tests
* remove createorg from service accounts
* remove createorg from accesscontrol tests
* remove createorg from provisioning
* Use quotaservice from sc.hs
* Storage: Add access for reporting
* reporting upload user per org
* add some basic comments
* Move reporting storage to enterprise
* add comments
Co-authored-by: Artur Wierzbicki <artur.wierzbicki@grafana.com>
* Nested Folders: Do not refer to the configuration for checking for the flag
Use always features.IsEnabled() instead
* Depend on the interface instead
This commit adds support for the From and To parameters that set the
time range for the graph. The default is 6 hours, which can sometimes
be too large of a time range.