Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,10 @@ processors:
attributes:
- key: "url.domain"
action: "insert"
### The following section will be updated by init_logging_facilities in common.sh
### BEGIN AUTO SECTION, DO NOT EDIT
# This is the domain of the URL that the logs are coming from
value: "<URL_DOMAIN>"
### END AUTO SECTION
value: "{{ grains.get('otel_guest_ip', '<GUEST_IP>') }}"
- key: "lit.subnet.id"
action: "insert"
### The following section will be updated by init_logging_facilities in common.sh
### BEGIN AUTO SECTION, DO NOT EDIT
# This is the subnet ID of the GCP project
value: "<SUBNET_ID>"
### END AUTO SECTION
value: "{{ grains.get('otel_guest_subnet_id', '<SUBNET_ID>') }}"

exporters:
googlecloud:
Expand Down
3 changes: 2 additions & 1 deletion components/common/salt/state/monitoring/otelcol/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ print_otelcol_notification:

/etc/monitoring/otelcol/otel-collector-config.yaml:
file.managed:
- source: salt://monitoring/otelcol/etc/otel-collector-config.yaml
- source: salt://monitoring/otelcol/etc/otel-collector-config.yaml.j2
- template: jinja
- mode: 0644
- makedirs: True

Expand Down
15 changes: 9 additions & 6 deletions components/guest/instance/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,16 @@ services:
- ${INSTANCE_LOGS_DIR}:/logs
EOF

# We also need to update the latest guest / subnet information in the otelcol config file.
local otel_collector_config_file="/etc/monitoring/otelcol/otel-collector-config.yaml"
# Set Salt grains with the guest's subnet and IP information for OTEL Collector config.
# Extract IP without CIDR notation (remove /XX suffix)
local ip_no_cidr="${NET4_IP%/*}"
sed -i "/# This is the domain of the URL that the logs are coming from/{n;s|.*| value: \"${ip_no_cidr}\"|}" ${otel_collector_config_file}
sed -i "/# This is the subnet ID of the GCP project/{n;s|.*| value: \"${local_subnet_id}\"|}" ${otel_collector_config_file}

systemctl stop otelcol
systemctl start otelcol
# Set grains for otel-collector config template
salt-call --local grains.setval otel_guest_ip "${ip_no_cidr}"
salt-call --local grains.setval otel_guest_subnet_id "${local_subnet_id}"

# Re-apply the otelcol state to regenerate the config with new grain values
salt-call --local state.apply monitoring.otelcol

systemctl restart otelcol
}