-
Notifications
You must be signed in to change notification settings - Fork 569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new command on mimirtool used to render template #7325
Add new command on mimirtool used to render template #7325
Conversation
26e4ad8
to
9e688d0
Compare
9e688d0
to
4581b2d
Compare
4581b2d
to
ef781c1
Compare
@@ -48,6 +48,10 @@ Mimirtool is a command-line tool that operators and tenants can use to execute a | |||
|
|||
For more information about the `backfill` command, refer to [Backfill]({{< relref "#backfill" >}}) | |||
|
|||
- The `template` command enables you to render your alertmanager template. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding a new top-level command template
, please make render
be a subcommand of alertmanager
: mimirtool alertmanager render <...>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got your point . I can change it but it might be confusing since it's doesn't do any interaction with the alertmanager that's why i used a new top-level command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved
alertmanager render --template-glob=TEMPLATE-GLOB --template-text=TEMPLATE-TEXT [<flags>]
Render a given definition in a template file to standard output.
nabil@laptop:~/mimir# go run cmd/mimirtool/main.go alertmanager --help
usage: mimirtool alertmanager [<flags>] <command> [<args> ...]
View and edit Alertmanager configurations that are stored in Grafana Mimir.
Flags:
--[no-]help Show context-sensitive help (also try --help-long and --help-man).
--log.level="info" set level of the logger
--push-gateway.endpoint=PUSH-GATEWAY.ENDPOINT
url for the push-gateway to register metrics
--push-gateway.job=PUSH-GATEWAY.JOB
job name to register metrics
--push-gateway.interval=1m interval to forward metrics to the push gateway
--user="" Basic auth API user to use when contacting Grafana Mimir; alternatively, set MIMIR_API_USER. If empty, MIMIR_TENANT_ID is used instead. ($MIMIR_API_USER)
--key="" Basic auth API key to use when contacting Grafana Mimir; alternatively, set MIMIR_API_KEY. ($MIMIR_API_KEY)
--tls-ca-path="" TLS CA certificate to verify Grafana Mimir API as part of mTLS; alternatively, set MIMIR_TLS_CA_PATH. ($MIMIR_TLS_CA_PATH)
--tls-cert-path="" TLS client certificate to authenticate with the Grafana Mimir API as part of mTLS; alternatively, set MIMIR_TLS_CERT_PATH. ($MIMIR_TLS_CERT_PATH)
--tls-key-path="" TLS client certificate private key to authenticate with the Grafana Mimir API as part of mTLS; alternatively, set MIMIR_TLS_KEY_PATH. ($MIMIR_TLS_KEY_PATH)
--[no-]tls-insecure-skip-verify
Skip TLS certificate verification; alternatively, set MIMIR_TLS_INSECURE_SKIP_VERIFY. ($MIMIR_TLS_INSECURE_SKIP_VERIFY)
--auth-token="" Authentication token bearer authentication; alternatively, set MIMIR_AUTH_TOKEN. ($MIMIR_AUTH_TOKEN)
--[no-]utf8-strict-mode Enable UTF-8 strict mode. Allows UTF-8 characters in the matchers for routes and inhibition rules, in silences, and in the labels for alerts.
Subcommands:
alertmanager get --address=ADDRESS --id=ID [<flags>]
Get the Alertmanager configuration that is currently in the Grafana Mimir Alertmanager.
alertmanager delete --address=ADDRESS --id=ID
Delete the Alertmanager configuration that is currently in the Grafana Mimir Alertmanager.
alertmanager load --address=ADDRESS --id=ID <config> [<template-files>...]
Load Alertmanager tenant configuration and template files into Grafana Mimir.
alertmanager verify <config> [<template-files>...]
Verify Alertmanager tenant configuration and template files.
alertmanager render --template-glob=TEMPLATE-GLOB --template-text=TEMPLATE-TEXT [<flags>]
Render a given definition in a template file to standard output.
nabil@laptop:~/mimir# go run cmd/mimirtool/main.go alertmanager render --help
usage: mimirtool alertmanager render --template-glob=TEMPLATE-GLOB --template-text=TEMPLATE-TEXT [<flags>]
Render a given definition in a template file to standard output.
Flags:
--[no-]help Show context-sensitive help (also try --help-long and --help-man).
--log.level="info" set level of the logger
--push-gateway.endpoint=PUSH-GATEWAY.ENDPOINT
url for the push-gateway to register metrics
--push-gateway.job=PUSH-GATEWAY.JOB
job name to register metrics
--push-gateway.interval=1m interval to forward metrics to the push gateway
--user="" Basic auth API user to use when contacting Grafana Mimir; alternatively, set MIMIR_API_USER. If empty, MIMIR_TENANT_ID is used instead. ($MIMIR_API_USER)
--key="" Basic auth API key to use when contacting Grafana Mimir; alternatively, set MIMIR_API_KEY. ($MIMIR_API_KEY)
--tls-ca-path="" TLS CA certificate to verify Grafana Mimir API as part of mTLS; alternatively, set MIMIR_TLS_CA_PATH. ($MIMIR_TLS_CA_PATH)
--tls-cert-path="" TLS client certificate to authenticate with the Grafana Mimir API as part of mTLS; alternatively, set MIMIR_TLS_CERT_PATH. ($MIMIR_TLS_CERT_PATH)
--tls-key-path="" TLS client certificate private key to authenticate with the Grafana Mimir API as part of mTLS; alternatively, set MIMIR_TLS_KEY_PATH. ($MIMIR_TLS_KEY_PATH)
--[no-]tls-insecure-skip-verify
Skip TLS certificate verification; alternatively, set MIMIR_TLS_INSECURE_SKIP_VERIFY. ($MIMIR_TLS_INSECURE_SKIP_VERIFY)
--auth-token="" Authentication token bearer authentication; alternatively, set MIMIR_AUTH_TOKEN. ($MIMIR_AUTH_TOKEN)
--[no-]utf8-strict-mode Enable UTF-8 strict mode. Allows UTF-8 characters in the matchers for routes and inhibition rules, in silences, and in the labels for alerts.
--template-glob=TEMPLATE-GLOB ...
Glob of paths that will be expanded and used for rendering.
--template-text=TEMPLATE-TEXT The template that will be rendered.
--template-type=TEMPLATE-TYPE The type of the template. Can be either text (default) or html.
--template-data=TEMPLATE-DATA Full path to a file which contains the data of the alert(-s) with which the --template-text will be rendered. Must be in JSON. File must be formatted
according to the following layout: https://pkg.go.dev/github.com/prometheus/alertmanager/template#Data. If none has been specified then a predefined,
simple alert will be used for rendering.
--id="" Basic auth username to use when contacting Prometheus or Grafana Mimir, also set as tenant ID; alternatively, set MIMIR_TENANT_ID. ($MIMIR_TENANT_ID)
Co-authored-by: Nick Pillitteri <[email protected]>
Co-authored-by: Nick Pillitteri <[email protected]>
d22ec9d
to
6ddbb07
Compare
6ddbb07
to
0f6554f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding some docs too!
I've added some suggestions to help make things more clear to a first time reader.
|
||
It can also take a glob path that will be expended. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given my other suggestion to move the options description before the comand example, I believe this can be removed.
It can also take a glob path that will be expended. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modification made. Is that okay for you ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM after the changes from @jdbaldry are implemented. @gotjosh or @grobinson-grafana, do you have any concerns about this new mimirtool
AM command?
Co-authored-by: Jack Baldry <[email protected]>
5a3c279
to
433c973
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
What this PR does
Add a new command on mimirtool useful to render template since mimir has some custom function that are not available in amtool.
This PR is based on this
I faced some issue when working on alert template i was using amtool to render template but cannot use
grafanaExploreURL
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
.about-versioning.md
updated with experimental features.