-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test showing how to use extraConfig and statsd (#1057)
* Add test showing how to use extraConfig and statsd Signed-off-by: Pete Wall <[email protected]> * Main, not hackathon Signed-off-by: Pete Wall <[email protected]> --------- Signed-off-by: Pete Wall <[email protected]>
- Loading branch information
Showing
5 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
charts/k8s-monitoring/tests/integration/statsd/deployments/grafana.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: grafana | ||
--- | ||
apiVersion: source.toolkit.fluxcd.io/v1 | ||
kind: HelmRepository | ||
metadata: | ||
name: grafana | ||
namespace: grafana | ||
spec: | ||
interval: 1m | ||
url: https://grafana.github.io/helm-charts | ||
--- | ||
apiVersion: helm.toolkit.fluxcd.io/v2 | ||
kind: HelmRelease | ||
metadata: | ||
name: grafana | ||
namespace: grafana | ||
spec: | ||
interval: 1m | ||
chart: | ||
spec: | ||
chart: grafana | ||
sourceRef: | ||
kind: HelmRepository | ||
name: grafana | ||
namespace: grafana | ||
interval: 1m | ||
values: | ||
datasources: | ||
datasources.yaml: | ||
apiVersion: 1 | ||
datasources: | ||
- name: Prometheus | ||
type: prometheus | ||
url: http://prometheus-server.prometheus.svc:9090 | ||
isDefault: true | ||
basicAuth: true | ||
basicAuthUser: promuser | ||
jsonData: | ||
tlsSkipVerify: true | ||
secureJsonData: | ||
basicAuthPassword: prometheuspassword | ||
|
||
- name: Loki | ||
type: loki | ||
url: http://loki-gateway.loki.svc:8080 | ||
basicAuth: true | ||
basicAuthUser: loki | ||
jsonData: | ||
httpHeaderName1: X-Scope-OrgID | ||
secureJsonData: | ||
basicAuthPassword: lokipassword | ||
httpHeaderValue1: "1" |
69 changes: 69 additions & 0 deletions
69
charts/k8s-monitoring/tests/integration/statsd/deployments/prometheus.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: prometheus | ||
--- | ||
apiVersion: source.toolkit.fluxcd.io/v1 | ||
kind: HelmRepository | ||
metadata: | ||
name: prometheus-community | ||
namespace: prometheus | ||
spec: | ||
interval: 1m | ||
url: https://prometheus-community.github.io/helm-charts | ||
--- | ||
apiVersion: helm.toolkit.fluxcd.io/v2 | ||
kind: HelmRelease | ||
metadata: | ||
name: prometheus | ||
namespace: prometheus | ||
spec: | ||
interval: 1m | ||
chart: | ||
spec: | ||
chart: prometheus | ||
version: "^25" | ||
sourceRef: | ||
kind: HelmRepository | ||
name: prometheus-community | ||
namespace: prometheus | ||
interval: 1m | ||
values: | ||
server: | ||
extraFlags: | ||
- enable-feature=otlp-write-receiver | ||
- enable-feature=remote-write-receiver | ||
|
||
persistentVolume: | ||
enabled: false | ||
|
||
probeHeaders: | ||
- name: "Authorization" | ||
value: "Basic cHJvbXVzZXI6cHJvbWV0aGV1c3Bhc3N3b3Jk" | ||
|
||
service: | ||
servicePort: 9090 | ||
|
||
serverFiles: | ||
prometheus.yml: | ||
scrape_configs: [] | ||
web.yml: | ||
basic_auth_users: | ||
promuser: $2a$12$1UJsAG4QnhjjDzqcSVkZmeDxxjgIFOAmzfuVTybTuhhDnYgfuAbAq # "prometheuspassword" | ||
|
||
configmapReload: | ||
prometheus: | ||
enabled: false | ||
|
||
alertmanager: | ||
enabled: false | ||
|
||
kube-state-metrics: | ||
enabled: false | ||
|
||
prometheus-node-exporter: | ||
enabled: false | ||
|
||
prometheus-pushgateway: | ||
enabled: false |
42 changes: 42 additions & 0 deletions
42
charts/k8s-monitoring/tests/integration/statsd/deployments/query-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
apiVersion: source.toolkit.fluxcd.io/v1 | ||
kind: GitRepository | ||
metadata: | ||
name: k8s-monitoring-test | ||
spec: | ||
interval: 1m | ||
url: https://github.com/grafana/k8s-monitoring-helm | ||
ref: | ||
branch: main | ||
ignore: | | ||
/* | ||
!/charts/k8s-monitoring-test | ||
--- | ||
apiVersion: helm.toolkit.fluxcd.io/v2 | ||
kind: HelmRelease | ||
metadata: | ||
name: k8s-monitoring-test | ||
spec: | ||
interval: 1m | ||
chart: | ||
spec: | ||
chart: charts/k8s-monitoring-test | ||
sourceRef: | ||
kind: GitRepository | ||
name: k8s-monitoring-test | ||
interval: 1m | ||
values: | ||
tests: | ||
- env: | ||
CLUSTER: statsd-test | ||
PROMETHEUS_URL: http://prometheus-server.prometheus.svc:9090/api/v1/query | ||
PROMETHEUS_USER: promuser | ||
PROMETHEUS_PASS: prometheuspassword | ||
queries: | ||
- query: example_gauge{cluster="$CLUSTER", job="integrations/statsd"} | ||
type: promql | ||
expect: | ||
operator: == | ||
value: 42 | ||
- query: statsd_exporter_build_info{cluster="$CLUSTER", job="integrations/statsd"} | ||
type: promql |
68 changes: 68 additions & 0 deletions
68
charts/k8s-monitoring/tests/integration/statsd/deployments/statsd-example.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: statsd-example | ||
data: | ||
statsd-example.js: | | ||
function sleep(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
async function main() { | ||
console.log('Starting statsd example'); | ||
const StatsD = require('node-statsd'); | ||
const client = new StatsD({ | ||
host: 'k8smon-alloy-receiver.default.svc', | ||
port: 8125, | ||
}); | ||
while (true) { | ||
console.log('Sending metric'); | ||
client.gauge('example.gauge', 42, function(error, bytes) { | ||
if (error) { | ||
console.error('Failed to send metric:', error); | ||
} else { | ||
console.log('Successfully sent', bytes, 'bytes'); | ||
} | ||
}); | ||
await sleep(10000); | ||
} | ||
client.close(); | ||
} | ||
main(); | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: statsd-example | ||
spec: | ||
initContainers: | ||
- name: dependencies | ||
image: node | ||
command: | ||
- bash | ||
- -c | ||
- | | ||
npm install node-statsd | ||
cp /src/statsd-example.js /workspace | ||
workingDir: /workspace | ||
volumeMounts: | ||
- name: workspace | ||
mountPath: /workspace | ||
- name: source | ||
mountPath: /src | ||
containers: | ||
- name: main | ||
image: node | ||
args: ["statsd-example.js"] | ||
workingDir: /workspace | ||
volumeMounts: | ||
- name: workspace | ||
mountPath: /workspace | ||
volumes: | ||
- name: workspace | ||
emptyDir: {} | ||
- name: source | ||
configMap: | ||
name: statsd-example |
35 changes: 35 additions & 0 deletions
35
charts/k8s-monitoring/tests/integration/statsd/values.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
cluster: | ||
name: statsd-test | ||
|
||
destinations: | ||
- name: localPrometheus | ||
type: prometheus | ||
url: http://prometheus-server.prometheus.svc:9090/api/v1/write | ||
auth: | ||
type: basic | ||
username: promuser | ||
password: prometheuspassword | ||
|
||
alloy-receiver: | ||
enabled: true | ||
alloy: | ||
extraPorts: | ||
- name: statsd-udp | ||
port: 8125 | ||
targetPort: 8125 | ||
protocol: UDP | ||
- name: statsd-tcp | ||
port: 8125 | ||
targetPort: 8125 | ||
protocol: TCP | ||
extraConfig: |- | ||
prometheus.exporter.statsd "default" { | ||
listen_udp = ":8125" | ||
listen_tcp = ":8125" | ||
parse_dogstatsd_tags = true | ||
} | ||
prometheus.scrape "statsd" { | ||
targets = prometheus.exporter.statsd.default.targets | ||
forward_to = [prometheus.remote_write.localprometheus.receiver] | ||
} |