grafana/pkg/services
Matthew Jacobson 940d18ad57
Alerting: Sanitize invalid label/annotation names for external alertmanagers (#54537)
* Alerting: Sanitize invalid label/annotation names for external alertmanagers

Grafana's built-in Alertmanager supports both Unicode label keys and values; however, if using an external
Prometheus Alertmanager label keys must be compatible with their data model.
This means label keys must only contain ASCII letters, numbers, as well as underscores and match the regex
`[a-zA-Z_][a-zA-Z0-9_]*`.

Any invalid characters will now be removed or replaced by the Grafana alerting engine before being sent to
the external Alertmanager according to the following rules:

- `Whitespace` will be removed.
- `ASCII characters` will be replaced with `_`.
- `All other characters` will be replaced with their lower-case hex representation.

* Prefix hex replacements with `0x`

* Refactor for clarity

* Apply suggestions from code review

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
2022-09-07 11:39:39 -04:00
..
accesscontrol RBAC: Move service and evaluator to acimpl package (#54714) 2022-09-05 18:15:47 +02:00
alerting manager exposes renderer + secrets manager (#54629) 2022-09-02 14:20:10 +02:00
annotations Move SignedInUser to user service and RoleType and Roles to org (#53445) 2022-08-10 11:56:48 +02:00
apikey Chore: move from xorm to sqlx apikey store (#53434) 2022-08-23 11:01:35 -04:00
auth Auth: Extend auth token errors with user ID (#54633) 2022-09-02 14:38:25 +01:00
cleanup Chore: Move login attempt methods to separate service (#54479) 2022-09-01 18:08:42 +02:00
comments Chore: Remove disable user, disable batch users and searchusers methods from store interface (#53717) 2022-08-16 14:24:57 +02:00
contexthandler JWT: Add support for assigning org roles (#54277) 2022-09-07 14:00:33 +02:00
correlations Correlations: Use correct fallback handlers (#54511) 2022-09-01 12:29:44 +02:00
dashboard_thumbs Chore: Add dashboard thumbnails service (#54500) 2022-08-31 16:45:41 -04:00
dashboardimport Chore: Add user service method SetUsingOrg and GetSignedInUserWithCacheCtx (#53343) 2022-08-11 13:28:55 +02:00
dashboards PublicDashboards: Add RBAC to secured endpoints (#54544) 2022-09-05 12:22:39 -03:00
dashboardsnapshots Chore: Add user service method SetUsingOrg and GetSignedInUserWithCacheCtx (#53343) 2022-08-11 13:28:55 +02:00
dashboardversion Chore: replace xorm by sqlx in dashboardversion service (#53869) 2022-08-25 16:04:16 -05:00
datasourceproxy backend/datasources: move datasources models into the datasources service package (#51267) 2022-06-27 12:23:15 -04:00
datasources Fix nil logger in SqlStore (#54726) 2022-09-05 18:24:19 +01:00
encryption Encryption: Fall back to AES-CFB on empty algorithm metadata (#53266) 2022-08-04 09:37:53 +02:00
export Chore: Add user service method SetUsingOrg and GetSignedInUserWithCacheCtx (#53343) 2022-08-11 13:28:55 +02:00
featuremgmt Plugins: Add feature toggles for long running queries (#54349) 2022-09-05 08:39:45 -07:00
guardian RBAC: Split up service into several components (#54002) 2022-08-24 13:29:17 +02:00
hooks Migrate to Wire for dependency injection (#32289) 2021-08-25 15:11:22 +02:00
kmsproviders Encryption: Refactor secrets.Service initialization (#51091) 2022-07-07 09:48:25 +02:00
ldap Handle ioutil deprecations (#53526) 2022-08-10 15:37:51 +02:00
libraryelements LibraryElements: Fix inability to delete library panels under MySQL (#54600) 2022-09-05 14:28:32 +01:00
librarypanels RBAC: Enable rbac when creating new settings (#53531) 2022-08-11 15:37:31 +02:00
licensing RBAC: Make RBAC action names more consistent (#49730) 2022-06-02 13:14:48 +01:00
live Chore: Add user service method SetUsingOrg and GetSignedInUserWithCacheCtx (#53343) 2022-08-11 13:28:55 +02:00
login RBAC: Split up service into several components (#54002) 2022-08-24 13:29:17 +02:00
loginattempt Chore: Move login attempt methods to separate service (#54479) 2022-09-01 18:08:42 +02:00
multildap Split Create User (#50502) 2022-06-28 14:32:25 +02:00
ngalert Alerting: Sanitize invalid label/annotation names for external alertmanagers (#54537) 2022-09-07 11:39:39 -04:00
notifications User management: Use HMAC-SHA256 to generate time limit codes (password reset tokens) (#42334) 2022-08-18 16:01:09 +02:00
oauthtoken Chore: Add user service method SetUsingOrg and GetSignedInUserWithCacheCtx (#53343) 2022-08-11 13:28:55 +02:00
org Chore: Move updateorg out of sqlstore (#54111) 2022-08-23 12:26:21 -05:00
playlist Chore: Replace xorm with sqlx (#52575) 2022-08-16 13:17:14 -05:00
plugindashboards Plugins: Split plugin manager into smaller components (#54384) 2022-08-30 17:30:43 +02:00
pluginsettings Chore: Move plugin settings store code into a dedicated service (#53560) 2022-08-11 09:50:53 +02:00
preference Chore: remove xorm from preference (#53803) 2022-08-17 22:07:20 -04:00
provisioning Alerting: use raw query data in provisioning to bypass interpolation of macros (#54293) 2022-08-26 23:54:30 +02:00
publicdashboards RBAC: Move service and evaluator to acimpl package (#54714) 2022-09-05 18:15:47 +02:00
query Public Dashboards: Add Expressions Support (#54336) 2022-08-31 09:11:10 -06:00
queryhistory Chore: Add user service method SetUsingOrg and GetSignedInUserWithCacheCtx (#53343) 2022-08-11 13:28:55 +02:00
quota Chore: Add user service method SetUsingOrg and GetSignedInUserWithCacheCtx (#53343) 2022-08-11 13:28:55 +02:00
rendering manager exposes renderer + secrets manager (#54629) 2022-09-02 14:20:10 +02:00
screenshot Move SignedInUser to user service and RoleType and Roles to org (#53445) 2022-08-10 11:56:48 +02:00
search Chore: Add user service method SetUsingOrg and GetSignedInUserWithCacheCtx (#53343) 2022-08-11 13:28:55 +02:00
searchusers Chore: Remove disable user, disable batch users and searchusers methods from store interface (#53717) 2022-08-16 14:24:57 +02:00
searchV2 Search: ordering tests (#54432) 2022-08-30 18:58:19 +02:00
secrets Secrets: Convert secret migration to a background service (#54676) 2022-09-06 16:21:25 -03:00
serviceaccounts RBAC: Remove DeclareFixedRoles wrapper on Access control and inject service (#54153) 2022-08-26 09:59:34 +02:00
shorturls Chore: Add user service method SetUsingOrg and GetSignedInUserWithCacheCtx (#53343) 2022-08-11 13:28:55 +02:00
sqlstore Admin: Add support to configure default admin email (#54363) 2022-09-07 14:38:40 +02:00
star add sqlx_store into star service (#53430) 2022-08-17 11:17:23 -05:00
store Storage: add WithContents option to storage.Get() (#53105) 2022-08-30 15:23:16 +02:00
teamguardian Chore: Add user service method SetUsingOrg and GetSignedInUserWithCacheCtx (#53343) 2022-08-11 13:28:55 +02:00
temp_user Chore: Add tempuser service (#53325) 2022-08-12 12:13:23 -04:00
thumbs manager exposes renderer + secrets manager (#54629) 2022-09-02 14:20:10 +02:00
updatechecker Handle ioutil deprecations (#53526) 2022-08-10 15:37:51 +02:00
user RBAC: Split up service into several components (#54002) 2022-08-24 13:29:17 +02:00
userauth Chore: Split delete user method (#52216) 2022-07-19 16:01:05 +02:00
validations Migrate to Wire for dependency injection (#32289) 2021-08-25 15:11:22 +02:00