Skip to content

Commit

Permalink
feat: enable hostmetrics for local deployment (#133)
Browse files Browse the repository at this point in the history
* feat: enable hostmetrics for local deployment

* docs: multiple ES environment variables

* disable k8s from eimp
  • Loading branch information
rogercoll authored Feb 14, 2025
1 parent 115967a commit 7e4b685
Show file tree
Hide file tree
Showing 2 changed files with 161 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Additionally, the OpenTelemetry Contrib collector has also been changed to the [
## Docker compose

1. Start a free trial on [Elastic Cloud](https://cloud.elastic.co/) and copy the `Elasticsearch endpoint` and the `API Key` from the `Help -> Connection details` drop down instructions in your Kibana. These variables will be used by the [elasticsearch exporter](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/elasticsearchexporter#elasticsearch-exporter) to authenticate and transmit data to your Elasticsearch instance.
2. Open the file `src/otelcollector/otelcol-elastic-config.yaml` in an editor and replace the following two placeholders:
2. Open the file `src/otelcollector/otelcol-elastic-config.yaml` in an editor and replace all occurrences the following two placeholders:
- `YOUR_ELASTICSEARCH_ENDPOINT`: your Elasticsearch endpoint (*with* `https://` prefix example: `https://1234567.us-west2.gcp.elastic-cloud.com:443`).
- `YOUR_ELASTICSEARCH_API_KEY`: your Elasticsearch API Key
3. Start the demo with the following command from the repository's root directory:
Expand Down
175 changes: 160 additions & 15 deletions src/otelcollector/otelcol-elastic-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
exporters:
debug:
elasticsearch/otel:
endpoints:
- "YOUR_ELASTICSEARCH_ENDPOINT"
api_key: "YOUR_ELASTICSEARCH_API_KEY"
logs_dynamic_index:
enabled: true
metrics_dynamic_index:
enabled: true
traces_dynamic_index:
enabled: true
mapping:
mode: otel
elasticsearch/ecs:
endpoints:
- "YOUR_ELASTICSEARCH_ENDPOINT"
api_key: "YOUR_ELASTICSEARCH_API_KEY"
logs_dynamic_index:
enabled: true
metrics_dynamic_index:
enabled: true
mapping:
mode: ecs

receivers:
otlp:
protocols:
Expand All @@ -12,24 +37,123 @@ receivers:
httpcheck/frontendproxy:
targets:
- endpoint: http://frontendproxy:${env:ENVOY_PORT}

exporters:
debug:
elasticsearch/otel:
endpoints:
- "YOUR_ELASTICSEARCH_ENDPOINT"
api_key: "YOUR_ELASTICSEARCH_API_KEY"
logs_dynamic_index:
enabled: true
metrics_dynamic_index:
enabled: true
traces_dynamic_index:
enabled: true
mapping:
mode: otel
hostmetrics:
collection_interval: 10s
root_path: /hostfs
scrapers:
cpu:
metrics:
system.cpu.utilization:
enabled: true
system.cpu.logical.count:
enabled: true
memory:
metrics:
system.memory.utilization:
enabled: true
process:
mute_process_exe_error: true
mute_process_io_error: true
mute_process_user_error: true
metrics:
process.threads:
enabled: true
process.open_file_descriptors:
enabled: true
process.memory.utilization:
enabled: true
process.disk.operations:
enabled: true
network:
processes:
load:
disk:
filesystem:
exclude_mount_points:
mount_points:
- /dev/*
- /proc/*
- /sys/*
- /run/k3s/containerd/*
- /var/lib/docker/*
- /var/lib/kubelet/*
- /snap/*
match_type: regexp
exclude_fs_types:
fs_types:
- autofs
- binfmt_misc
- bpf
- cgroup2
- configfs
- debugfs
- devpts
- devtmpfs
- fusectl
- hugetlbfs
- iso9660
- mqueue
- nsfs
- overlay
- proc
- procfs
- pstore
- rpc_pipefs
- securityfs
- selinuxfs
- squashfs
- sysfs
- tracefs
match_type: strict

processors:
batch:
elasticinframetrics:
add_system_metrics: true
add_k8s_metrics: false
drop_original: true
resource/process:
attributes:
- key: process.executable.name
action: delete
- key: process.executable.path
action: delete
attributes/dataset:
actions:
- key: event.dataset
from_attribute: data_stream.dataset
action: upsert
resourcedetection/system:
detectors: ["system"]
system:
hostname_sources: ["os"]
resource_attributes:
host.name:
enabled: true
host.id:
enabled: false
host.arch:
enabled: true
host.ip:
enabled: true
host.mac:
enabled: true
host.cpu.vendor.id:
enabled: true
host.cpu.family:
enabled: true
host.cpu.model.id:
enabled: true
host.cpu.model.name:
enabled: true
host.cpu.stepping:
enabled: true
host.cpu.cache.l2.size:
enabled: true
os.description:
enabled: true
os.type:
enabled: true
transform:
error_mode: ignore
trace_statements:
Expand Down Expand Up @@ -304,6 +428,27 @@ service:
- batch
receivers:
- otlp
metrics/infra/ecs:
exporters:
- elasticsearch/ecs
- debug
processors:
- batch
- elasticinframetrics
- resourcedetection/system
- attributes/dataset
- resource/process
receivers:
- hostmetrics
metrics/infra/otel:
exporters:
- elasticsearch/otel
- debug
processors:
- batch
- resourcedetection/system
receivers:
- hostmetrics
metrics:
exporters:
- elasticsearch/otel
Expand Down

0 comments on commit 7e4b685

Please sign in to comment.