Skip to content

Commit

Permalink
Added Auto-Configure Example
Browse files Browse the repository at this point in the history
  • Loading branch information
bentonam committed Jun 10, 2024
1 parent d153030 commit a5b6544
Show file tree
Hide file tree
Showing 7 changed files with 57,865 additions and 0 deletions.
78 changes: 78 additions & 0 deletions examples/credentials-autoconfigure-grafana-cloud/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Credentials Auto-Configured from Grafana Cloud

This example shows how to auto-configure the external services using a single token from an API call to Grafana Cloud. The token must have `metrics:write`, `logs:write`, `traces:write`, `profiles:write` and `stacks:read` permissions. Credit [theSuess](https://github.com/theSuess) for providing the original [example](https://github.com/grafana/agent-modules/blob/main/modules/grafana-cloud/autoconfigure/module.river).

```yaml
---
cluster:
name: credentials-auto-configure

externalServices:
prometheus:
hostFrom: json_decode(remote.http.config_file.content)["hmInstancePromUrl"] + "/api/prom/push"
basicAuth:
usernameFrom: json_decode(remote.http.config_file.content)["hmInstancePromId"]
passwordFrom: remote.kubernetes.secret.grafana_cloud.data["token"]
secret:
create: false
loki:
hostFrom: json_decode(remote.http.grafana_cloud.content)["hlInstanceUrl"] + "/loki/api/v1/push"
basicAuth:
usernameFrom: json_decode(remote.http.config_file.content)["hlInstanceId"]
passwordFrom: remote.kubernetes.secret.grafana_cloud.data["token"]
secret:
create: false
tempo:
hostFrom: json_decode(remote.http.config_file.content)["htInstanceUrl"] + ":443"
basicAuth:
usernameFrom: json_decode(remote.http.config_file.content)["htInstanceId"]
passwordFrom: remote.kubernetes.secret.grafana_cloud.data["token"]
secret:
create: false
pyroscope:
hostFrom: json_decode(remote.http.config_file.content)["hpInstanceUrl"]
basicAuth:
usernameFrom: json_decode(remote.http.config_file.content)["hpInstanceId"]
passwordFrom: remote.kubernetes.secret.grafana_cloud.data["token"]
secret:
create: false
global:
extraConfig: |-
remote.kubernetes.secret "grafana_cloud" {
namespace = "default"
name = "grafana-cloud-credentials"
}
remote.http "grafana_cloud" {
// replace YOURSTACKNAME with the name of your stack name
// The API Token must have the stacks:read
url = "https://grafana.com/api/instances/YOURSTACKNAME
client {
bearer_token = remote.kubernetes.secret.grafana_cloud.data["token"]
}
poll_frequency = "24h"
}
logs:
enabled: true
pod_logs:
enabled: true
cluster_events:
enabled: true
journal:
enabled: true

traces:
enabled: true

profiles:
enabled: true

extraObjects:
- apiVersion: v1
kind: Secret
metadata:
name: grafana-cloud-credentials
type: Opaque
data:
token: SXQncyBhIHNlY3JldCB0byBldmVyeW9uZQ==
```
47 changes: 47 additions & 0 deletions examples/credentials-autoconfigure-grafana-cloud/events.alloy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

181 changes: 181 additions & 0 deletions examples/credentials-autoconfigure-grafana-cloud/logs.alloy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a5b6544

Please sign in to comment.