Skip to content

Commit

Permalink
Update the remoteconfig platform test to set the expected env vars (#…
Browse files Browse the repository at this point in the history
…1107)

* Update the remoteconfig platform test to set the expected environment variables

Signed-off-by: Pete Wall <[email protected]>

* Update the remotecfg example to bring in the right environment variables

Signed-off-by: Pete Wall <[email protected]>

* Update the remote config example and platform test to enforce setting the right environment variables

Signed-off-by: Pete Wall <[email protected]>

* Update examples

Signed-off-by: Pete Wall <[email protected]>

---------

Signed-off-by: Pete Wall <[email protected]>
  • Loading branch information
petewall authored Jan 24, 2025
1 parent 7341103 commit 0a73718
Show file tree
Hide file tree
Showing 14 changed files with 1,083 additions and 61 deletions.
9 changes: 8 additions & 1 deletion charts/k8s-monitoring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ podLogs:
| alloy-logs.remoteConfig.auth.usernameFrom | string | `""` | Raw config for accessing the username. |
| alloy-logs.remoteConfig.auth.usernameKey | string | `"username"` | The key for storing the username in the secret. |
| alloy-logs.remoteConfig.enabled | bool | `false` | Enable fetching configuration from a remote config server. |
| alloy-logs.remoteConfig.extraAttributes | object | `{}` | Attributes to be added to this collector when requesting configuration. |
| alloy-logs.remoteConfig.pollFrequency | string | `"5m"` | The frequency at which to poll the remote config server for updates. |
| alloy-logs.remoteConfig.secret.create | bool | `true` | Whether to create a secret for the remote config server. |
| alloy-logs.remoteConfig.secret.embed | bool | `false` | If true, skip secret creation and embed the credentials directly into the configuration. |
| alloy-logs.remoteConfig.secret.name | string | `""` | The name of the secret to create. |
Expand All @@ -187,7 +189,6 @@ podLogs:
| alloy-metrics.remoteConfig.auth.usernameKey | string | `"username"` | The key for storing the username in the secret. |
| alloy-metrics.remoteConfig.enabled | bool | `false` | Enable fetching configuration from a remote config server. |
| alloy-metrics.remoteConfig.extraAttributes | object | `{}` | Attributes to be added to this collector when requesting configuration. |
| alloy-metrics.remoteConfig.id | string | `<cluster>-<namespace>-<pod-name>` | The unique identifier for this Alloy instance. |
| alloy-metrics.remoteConfig.pollFrequency | string | `"5m"` | The frequency at which to poll the remote config server for updates. |
| alloy-metrics.remoteConfig.secret.create | bool | `true` | Whether to create a secret for the remote config server. |
| alloy-metrics.remoteConfig.secret.embed | bool | `false` | If true, skip secret creation and embed the credentials directly into the configuration. |
Expand All @@ -213,6 +214,8 @@ podLogs:
| alloy-profiles.remoteConfig.auth.usernameFrom | string | `""` | Raw config for accessing the username. |
| alloy-profiles.remoteConfig.auth.usernameKey | string | `"username"` | The key for storing the username in the secret. |
| alloy-profiles.remoteConfig.enabled | bool | `false` | Enable fetching configuration from a remote config server. |
| alloy-profiles.remoteConfig.extraAttributes | object | `{}` | Attributes to be added to this collector when requesting configuration. |
| alloy-profiles.remoteConfig.pollFrequency | string | `"5m"` | The frequency at which to poll the remote config server for updates. |
| alloy-profiles.remoteConfig.secret.create | bool | `true` | Whether to create a secret for the remote config server. |
| alloy-profiles.remoteConfig.secret.embed | bool | `false` | If true, skip secret creation and embed the credentials directly into the configuration. |
| alloy-profiles.remoteConfig.secret.name | string | `""` | The name of the secret to create. |
Expand All @@ -238,6 +241,8 @@ podLogs:
| alloy-receiver.remoteConfig.auth.usernameFrom | string | `""` | Raw config for accessing the username. |
| alloy-receiver.remoteConfig.auth.usernameKey | string | `"username"` | The key for storing the username in the secret. |
| alloy-receiver.remoteConfig.enabled | bool | `false` | Enable fetching configuration from a remote config server. |
| alloy-receiver.remoteConfig.extraAttributes | object | `{}` | Attributes to be added to this collector when requesting configuration. |
| alloy-receiver.remoteConfig.pollFrequency | string | `"5m"` | The frequency at which to poll the remote config server for updates. |
| alloy-receiver.remoteConfig.secret.create | bool | `true` | Whether to create a secret for the remote config server. |
| alloy-receiver.remoteConfig.secret.embed | bool | `false` | If true, skip secret creation and embed the credentials directly into the configuration. |
| alloy-receiver.remoteConfig.secret.name | string | `""` | The name of the secret to create. |
Expand All @@ -263,6 +268,8 @@ podLogs:
| alloy-singleton.remoteConfig.auth.usernameFrom | string | `""` | Raw config for accessing the username. |
| alloy-singleton.remoteConfig.auth.usernameKey | string | `"username"` | The key for storing the username in the secret. |
| alloy-singleton.remoteConfig.enabled | bool | `false` | Enable fetching configuration from a remote config server. |
| alloy-singleton.remoteConfig.extraAttributes | object | `{}` | Attributes to be added to this collector when requesting configuration. |
| alloy-singleton.remoteConfig.pollFrequency | string | `"5m"` | The frequency at which to poll the remote config server for updates. |
| alloy-singleton.remoteConfig.secret.create | bool | `true` | Whether to create a secret for the remote config server. |
| alloy-singleton.remoteConfig.secret.embed | bool | `false` | If true, skip secret creation and embed the credentials directly into the configuration. |
| alloy-singleton.remoteConfig.secret.name | string | `""` | The name of the secret to create. |
Expand Down
63 changes: 60 additions & 3 deletions charts/k8s-monitoring/docs/examples/remote-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,22 @@
# Remote Config

This example demonstrates how to configure Alloy to utilize
[remote configuration](https://grafana.com/docs/alloy/latest/reference/config-blocks/remotecfg/).
[remote configuration](https://grafana.com/docs/alloy/latest/reference/config-blocks/remotecfg/). These two environment
variables must be set:

* `GCLOUD_FM_COLLECTOR_ID` - The collector id. It should uniquely identify this Alloy instance. The value in practice is:
* For Deployments: `<cluster name>-<namespace>-<pod name>`
* For StatefulSets: `<cluster name>-<namespace>-<pod name>`
* For DaemonSets: `<cluster name>-<namespace>-<node name>`
* `GCLOUD_RW_API_KEY` - The Grafana Cloud Access Policy token that has following scopes:
* `fleet-management:read`
* `logs:write`
* `metrics:write`
* `traces:write`
* `profiles:write`

The values file below shows enabling the `alloy-metrics` StatefulSet and the `alloy-logs` DaemonSets and a convenient
way to set the environment variables automatically.

## Values

Expand All @@ -16,13 +31,55 @@ cluster:

alloy-metrics:
enabled: true
remoteConfig:
enabled: true
url: https://remote-config.example.com/alloy
auth:
type: basic
username: my-remote-cfg-user
passwordFrom: sys.env("GCLOUD_RW_API_KEY")
alloy:
stabilityLevel: public-preview
extraEnv:
- name: CLUSTER_NAME
value: remote-config-example-cluster
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: GCLOUD_FM_COLLECTOR_ID
value: $(CLUSTER_NAME)-$(NAMESPACE)-$(POD_NAME)
- name: GCLOUD_RW_API_KEY
value: my-remote-cfg-password

alloy-logs:
enabled: true
remoteConfig:
enabled: true
url: "https://remote-config.example.com/alloy"
auth:
type: "basic"
type: basic
username: "my-remote-cfg-user"
password: "my-remote-cfg-password"
passwordFrom: sys.env("GCLOUD_RW_API_KEY")
alloy:
stabilityLevel: public-preview
extraEnv:
- name: CLUSTER_NAME
value: remote-config-example-cluster
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: GCLOUD_FM_COLLECTOR_ID
value: $(CLUSTER_NAME)-$(NAMESPACE)-$(NODE_NAME)
- name: GCLOUD_RW_API_KEY
value: "my-remote-cfg-password"
```
26 changes: 26 additions & 0 deletions charts/k8s-monitoring/docs/examples/remote-config/alloy-logs.alloy

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

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

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

Loading

0 comments on commit 0a73718

Please sign in to comment.