Skip to content

Commit 8006d74

Browse files
committed
feat: add percona mongodb-exporter + smartctl-exporter sidecars
Add two more metrics sidecars to the provider stack and wire them into vector's remote-write pipeline: - mongodb-exporter (percona/mongodb_exporter): richer mongo metrics (replication, per-collection/index stats, query exec, connection pool) on :9216, beyond the basic server status from vector's built-in mongodb_metrics source. URI passed via env, not --mongodb.uri, to keep the password out of the container's process args. - smartctl-exporter: disk SMART health (reallocated sectors, temperature, wear, predicted failure) on :9633, not captured by host_metrics/cadvisor. vector.toml gains prometheus_scrape sources for both and includes them in both OpenObserve remote-write sinks. Also address review feedback: switch redis-exporter depends_on to the list form (no conditional depends_on elsewhere in the repo's compose).
1 parent f69c715 commit 8006d74

2 files changed

Lines changed: 108 additions & 4 deletions

File tree

docker/docker-compose.provider.yml

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ services:
187187
env_file:
188188
- ../.env.1.${NODE_ENV}
189189
depends_on:
190-
redis-stack:
191-
condition: service_started
190+
- redis-stack
192191
restart: unless-stopped # unless the container has been stopped, it will be restarted, even on reboot
193192
expose:
194193
- "9121"
@@ -240,6 +239,71 @@ services:
240239
options:
241240
max-size: '100m'
242241
max-file: '1'
242+
mongodb-exporter:
243+
# Percona MongoDB exporter: richer mongo metrics (replication, per-collection
244+
# & index stats, query exec stats, connection pool) in Prometheus format on
245+
# :9216, scraped by vector (sources.mongodb_exporter_metrics ->
246+
# http://mongodb-exporter:9216/metrics). Complements vector's built-in
247+
# mongodb_metrics source, which only exposes basic server status.
248+
container_name: mongodb-exporter
249+
profiles:
250+
- production
251+
- staging
252+
image: percona/mongodb_exporter:${MONGODB_EXPORTER_IMAGE:-0.43.1}
253+
labels:
254+
- "vector.docker=true" # log docker events
255+
# MONGODB_URI is resolved by compose interpolation from the deploy-exported
256+
# provider env (same MONGO_INITDB_ROOT_* values the database/vector services
257+
# use). Passed via env rather than --mongodb.uri so the password isn't
258+
# visible in the container's process args. --collect-all enables all
259+
# collectors; --compatible-mode keeps metric names stable for dashboards.
260+
environment:
261+
- MONGODB_URI=mongodb://${MONGO_INITDB_ROOT_USERNAME:-root}:${MONGO_INITDB_ROOT_PASSWORD:-root}@database:27017
262+
command:
263+
- '--collect-all'
264+
- '--compatible-mode'
265+
env_file:
266+
- ../.env.1.${NODE_ENV}
267+
depends_on:
268+
- database
269+
restart: unless-stopped # unless the container has been stopped, it will be restarted, even on reboot
270+
expose:
271+
- "9216"
272+
networks:
273+
internal:
274+
ipv4_address: 172.18.0.13
275+
ipv6_address: fd00:aaaa::d
276+
logging:
277+
driver: 'json-file'
278+
options:
279+
max-size: '100m'
280+
max-file: '1'
281+
smartctl-exporter:
282+
# Disk SMART health metrics (reallocated sectors, temperature, wear,
283+
# predicted failure) in Prometheus format on :9633, scraped by vector
284+
# (sources.smartctl_metrics -> http://smartctl-exporter:9633/metrics).
285+
# Needs privileged + host /dev access to issue SMART commands to the disks.
286+
container_name: smartctl-exporter
287+
profiles:
288+
- production
289+
- staging
290+
image: prometheuscommunity/smartctl-exporter:${SMARTCTL_EXPORTER_IMAGE:-v0.13.0}
291+
labels:
292+
- "vector.docker=true" # log docker events
293+
privileged: true
294+
user: root
295+
restart: unless-stopped # unless the container has been stopped, it will be restarted, even on reboot
296+
expose:
297+
- "9633"
298+
networks:
299+
internal:
300+
ipv4_address: 172.18.0.14
301+
ipv6_address: fd00:aaaa::e
302+
logging:
303+
driver: 'json-file'
304+
options:
305+
max-size: '100m'
306+
max-file: '1'
243307
vector:
244308
container_name: vector
245309
profiles:

docker/images/vector/src/vector.toml

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,46 @@ source = '''
809809
.tags.env=get_env_var!("NODE_ENV")
810810
'''
811811

812+
# =============================================================================
813+
# MONGODB EXPORTER METRICS (Percona)
814+
# =============================================================================
815+
# Source: Richer MongoDB metrics from the percona/mongodb_exporter sidecar.
816+
# Adds replication, per-collection/index stats, query exec stats and connection
817+
# pool detail that the built-in mongodb_metrics source above does not expose.
818+
[sources.mongodb_exporter_metrics]
819+
type = "prometheus_scrape"
820+
endpoints = [ "http://mongodb-exporter:9216/metrics" ]
821+
scrape_interval_secs = 30
822+
823+
# Transform: Add host and environment tags to MongoDB exporter metrics
824+
[transforms.mongodb_exporter_metrics_format]
825+
type = "remap"
826+
inputs = ["mongodb_exporter_metrics"]
827+
source = '''
828+
.tags.host=get_env_var!("OO_HOST")
829+
.tags.env=get_env_var!("NODE_ENV")
830+
'''
831+
832+
# =============================================================================
833+
# SMARTCTL DISK HEALTH METRICS
834+
# =============================================================================
835+
# Source: Disk SMART health metrics from the smartctl-exporter sidecar.
836+
# Reallocated sectors, temperature, wear levelling and predicted failure for the
837+
# host's physical disks — not captured by host_metrics or cadvisor.
838+
[sources.smartctl_metrics]
839+
type = "prometheus_scrape"
840+
endpoints = [ "http://smartctl-exporter:9633/metrics" ]
841+
scrape_interval_secs = 30
842+
843+
# Transform: Add host and environment tags to smartctl metrics
844+
[transforms.smartctl_metrics_format]
845+
type = "remap"
846+
inputs = ["smartctl_metrics"]
847+
source = '''
848+
.tags.host=get_env_var!("OO_HOST")
849+
.tags.env=get_env_var!("NODE_ENV")
850+
'''
851+
812852
# =============================================================================
813853
# METRICS SINKS
814854
# =============================================================================
@@ -817,7 +857,7 @@ source = '''
817857
# Uses Prometheus Remote Write protocol for efficient metric transmission
818858
[sinks.oo_metrics]
819859
type = "prometheus_remote_write"
820-
inputs = ["host_metrics_format", "vector_metrics_format", "cadvisor_metrics_format", "mongodb_metrics_format", "redis_metrics_format", "caddy_metrics_format"]
860+
inputs = ["host_metrics_format", "vector_metrics_format", "cadvisor_metrics_format", "mongodb_metrics_format", "mongodb_exporter_metrics_format", "smartctl_metrics_format", "redis_metrics_format", "caddy_metrics_format"]
821861
endpoint = "https://oo.prosopo.io/api/dev_organization_29569_u24VnjrjN7XrP35/prometheus/api/v1/write"
822862

823863
[sinks.oo_metrics.auth]
@@ -844,7 +884,7 @@ when_full = "drop_newest"
844884
# Backup destination for metrics redundancy and disaster recovery
845885
[sinks.oo2_metrics]
846886
type = "prometheus_remote_write"
847-
inputs = ["host_metrics_format", "vector_metrics_format", "cadvisor_metrics_format", "mongodb_metrics_format", "redis_metrics_format", "caddy_metrics_format"]
887+
inputs = ["host_metrics_format", "vector_metrics_format", "cadvisor_metrics_format", "mongodb_metrics_format", "mongodb_exporter_metrics_format", "smartctl_metrics_format", "redis_metrics_format", "caddy_metrics_format"]
848888
endpoint = "https://oo2.prosopo.io/api/default/prometheus/api/v1/write"
849889

850890
[sinks.oo2_metrics.auth]

0 commit comments

Comments
 (0)