Skip to content

Commit

Permalink
feat(loki) : upgrade loki endpoint url
Browse files Browse the repository at this point in the history
what :

According to the documentation :

https://grafana.com/docs/loki/latest/api/#post-apiprompush

/api/prom/push is deprecated and is replaced by /loki/api/v1/push

why :

standard api update

We are allowing the configuration of the endpoint .
This will NOT break alreadyu deployed lokisidekcick and is still futur
proof

Signed-off-by: Julien Godin <julien.godin@camptocamp.com>
  • Loading branch information
JGodin-C2C authored and poiana committed Apr 26, 2022
1 parent 09387d8 commit 4ebeb04
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ loki:
# minimumpriority: "" # minimum priority of event for using this output, order is emergency|alert|critical|error|warning|notice|informational|debug or "" (default)
# checkcert: true # check if ssl certificate of the output is valid (default: true)
# tenant: "" # Add the tenant header if needed. Enabled if not empty
# endpoint: "/api/prom/push" # The endpoint URL path, default is "/api/prom/push" more info : https://grafana.com/docs/loki/latest/api/#post-apiprompush

stan:
# hostport: "" # nats://{domain or ip}:{port}, if not empty, STAN output is enabled
Expand Down Expand Up @@ -604,6 +605,7 @@ care of lower/uppercases**) : `yaml: a.b --> envvar: A_B` :
- **LOKI_CHECKCERT** : check if ssl certificate of the output is valid (default:
`true`)
- **LOKI_TENANT** : Loki tenant, if not `empty`, Loki tenant is _enabled_
- **LOKI_ENDPOINT** : Loki endpoint URL path, default is "/api/prom/push" more info : https://grafana.com/docs/loki/latest/api/#post-apiprompush
- **NATS_HOSTPORT** : NATS "nats://host:port", if not `empty`, NATS is _enabled_
- **NATS_MINIMUMPRIORITY** : minimum priority of event for using this output,
order is
Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func getConfig() *types.Configuration {
v.SetDefault("Loki.MutualTLS", false)
v.SetDefault("Loki.CheckCert", true)
v.SetDefault("Loki.Tenant", "")
v.SetDefault("Loki.Endpoint", "/api/prom/push")

v.SetDefault("AWS.AccessKeyID", "")
v.SetDefault("AWS.SecretAccessKey", "")
Expand Down
1 change: 1 addition & 0 deletions config_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ loki:
# mutualtls: false # if true, checkcert flag will be ignored (server cert will always be checked)
# checkcert: true # check if ssl certificate of the output is valid (default: true)
# tenant: "" # Add the tenant header if needed. Tenant header is enabled only if not empty
# endpoint: "/api/prom/push" # The endpoint URL path, default is "/api/prom/push" more info : https://grafana.com/docs/loki/latest/api/#post-apiprompush

nats:
# hostport: "" # nats://{domain or ip}:{port}, if not empty, NATS output is enabled
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func init() {

if config.Loki.HostPort != "" {
var err error
lokiClient, err = outputs.NewClient("Loki", config.Loki.HostPort+"/api/prom/push", config.Loki.MutualTLS, config.Loki.CheckCert, config, stats, promStats, statsdClient, dogstatsdClient)
lokiClient, err = outputs.NewClient("Loki", config.Loki.HostPort+config.Loki.Endpoint, config.Loki.MutualTLS, config.Loki.CheckCert, config, stats, promStats, statsdClient, dogstatsdClient)
if err != nil {
config.Loki.HostPort = ""
} else {
Expand Down
1 change: 1 addition & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ type lokiOutputConfig struct {
CheckCert bool
MutualTLS bool
Tenant string
Endpoint string
}

type natsOutputConfig struct {
Expand Down

0 comments on commit 4ebeb04

Please sign in to comment.