Skip to content

Commit

Permalink
Merge cluster level metrics with demo and add additional daemonset
Browse files Browse the repository at this point in the history
Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
  • Loading branch information
ChrsMark committed Nov 28, 2023
1 parent 4bab777 commit 8ee60c6
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 98 deletions.
60 changes: 7 additions & 53 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,59 +48,13 @@ The following guide describes how to setup the OpenTelemetry demo with Elastic O

#### Kubernetes monitoring

##### Kubernetes infrastructure monitoring

In `opentelemetry-collector` section uncomment the following to enable the k8s node level monitoring.
This will enable metrics' collection on node level as well as logs collection from Pods.
```yml
mode: "daemonset"
presets:
kubernetesAttributes:
enabled: true
kubeletMetrics:
enabled: true
hostMetrics:
enabled: true
logsCollection:
enabled: true
includeCollectorLogs: false
storeCheckpoints: true
```
##### Kubernetes Pod autodiscovery
Under `config` section enable the `k8s_observer` with the following:

```yml
extensions:
k8s_observer:
auth_type: serviceAccount
node: ${env:K8S_NODE_NAME}
observe_pods: true
```

Then under `receivers` section enable the Redis receiver based on an autodiscovery rule:

```yml
receiver_creator:
watch_observers: [ k8s_observer ]
receivers:
redis:
rule: type == "port" && pod.name matches "redis"
config:
collection_interval: 2s
```

Under `service` section add the `extensions`:

```yml
extensions: [k8s_observer]
```

and register the `receiver_creator` in the `metrics` `receivers` list:
```yml
receivers: [otlp, receiver_creator]
```
This demo already enables cluster level metrics collection with `clusterMetrics` and
Kubernetes events collection with `kubernetesEvents`.

In order to add Node level metrics collection and autodiscovery for Redis Pods
we can run an additional Otel collector Daemonset with the following:

`helm install daemonset open-telemetry/opentelemetry-collector --values daemonset.yaml`

## Explore and analyze the data With Elastic

Expand Down
56 changes: 56 additions & 0 deletions kubernetes/elastic-helm/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
mode: daemonset
presets:
logsCollection:
enabled: true
hostMetrics:
enabled: true
kubeletMetrics:
enabled: true
kubernetesAttributes:
enabled: true

extraEnvs:
- name: ELASTIC_APM_ENDPOINT
valueFrom:
secretKeyRef:
name: elastic-secret
key: elastic_apm_endpoint
- name: ELASTIC_APM_SECRET_TOKEN
valueFrom:
secretKeyRef:
name: elastic-secret
key: elastic_apm_secret_token

config:
extensions:
k8s_observer:
auth_type: serviceAccount
node: ${env:K8S_NODE_NAME}
observe_pods: true
exporters:
otlp/elastic:
endpoint: ${ELASTIC_APM_ENDPOINT}
compression: none
headers:
Authorization: Bearer ${ELASTIC_APM_SECRET_TOKEN}
receivers:
receiver_creator:
watch_observers: [ k8s_observer ]
receivers:
redis:
rule: type == "port" && pod.name matches "redis"
config:
collection_interval: 2s
service:
extensions: [k8s_observer]
pipelines:
traces:
processors: [batch]
exporters: [otlp/elastic]
metrics:
receivers: [ receiver_creator]
processors: [batch]
exporters: [otlp/elastic]
logs:
processors: [batch]
exporters: [otlp/elastic]
54 changes: 9 additions & 45 deletions kubernetes/elastic-helm/values.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
opentelemetry-collector:
# Uncomment these lines to enable k8s infra monitoring.
# Note that only node level metrics will be collected since cluster level metrics
# require "deployment" mode
# mode: "daemonset"
# presets:
# kubernetesAttributes:
# enabled: true
# kubeletMetrics:
# enabled: true
# hostMetrics:
# enabled: true
# logsCollection:
# enabled: true
# includeCollectorLogs: false
# storeCheckpoints: true
#
# Uncomment these lines to enable k8s cluster level metrics.
# At the moment it cannot be used along with the node level metrics from above.
# mode: "deployment"
# presets:
# kubernetesAttributes:
# enabled: true
# clusterMetrics:
# enabled: true
mode: "deployment"
presets:
kubernetesAttributes:
enabled: true
kubernetesEvents:
enabled: true
clusterMetrics:
enabled: true

extraEnvs:
- name: ELASTIC_APM_ENDPOINT
valueFrom:
Expand All @@ -35,30 +20,13 @@ opentelemetry-collector:
name: elastic-secret
key: elastic_apm_secret_token
config:
# k8s_observer section enables the k8s autodiscovery observer
# With this enabled we can automatically enable service specific receivers
# based on conditions
# extensions:
# k8s_observer:
# auth_type: serviceAccount
# node: ${env:K8S_NODE_NAME}
# observe_pods: true
exporters:
otlp/elastic:
endpoint: ${ELASTIC_APM_ENDPOINT}
compression: none
headers:
Authorization: Bearer ${ELASTIC_APM_SECRET_TOKEN}
receivers:
# receiver_creator enables service specific receivers
# based on conditions
# receiver_creator:
# watch_observers: [ k8s_observer ]
# receivers:
# redis:
# rule: type == "port" && pod.name matches "redis"
# config:
# collection_interval: 2s
otlp:
protocols:
grpc:
Expand All @@ -70,17 +38,13 @@ opentelemetry-collector:
- https://*
endpoint: ${MY_POD_IP}:4318
service:
# Enable extensions
# extensions: [k8s_observer]
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [otlp/elastic]
metrics:
receivers: [otlp]
# Add the receiver_creator
# receivers: [otlp, receiver_creator]
processors: [batch]
exporters: [otlp/elastic]
logs:
Expand Down

0 comments on commit 8ee60c6

Please sign in to comment.