Skip to content

Commit f14c244

Browse files
authored
Merge pull request #6422 from influxdata:influxdb3-monitor-metrics
Influxdb3 monitor metrics
2 parents d79a6d7 + ad3b0e5 commit f14c244

31 files changed

+5357
-13
lines changed

TESTING.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,117 @@ Potential causes:
121121
# This is ignored
122122
```
123123

124+
### Metrics Endpoint Testing
125+
126+
The metrics testing suite validates InfluxDB 3 Core and Enterprise metrics in two phases:
127+
128+
1. **Phase 1: Direct metrics validation** - Validates metric format, existence, and types by directly querying InfluxDB endpoints
129+
2. **Phase 2: Prometheus integration** - Validates Prometheus configuration, scraping, and relabeling work as documented
130+
131+
#### Phase 1: Direct Metrics Validation
132+
133+
The `test/influxdb3/metrics_endpoint_test.py` suite validates that InfluxDB 3 metrics endpoints expose all documented metrics in correct Prometheus format.
134+
135+
**Basic Usage:**
136+
137+
```bash
138+
# Using the wrapper script (recommended)
139+
./test/run-metrics-tests.sh
140+
141+
# Direct execution with Docker Compose
142+
docker compose run --rm influxdb3-core-pytest test/influxdb3/metrics_endpoint_test.py
143+
144+
# Run specific test
145+
docker compose run --rm influxdb3-core-pytest test/influxdb3/metrics_endpoint_test.py -k test_http_grpc_metrics
146+
```
147+
148+
**Verbose Output:**
149+
150+
Set `VERBOSE_METRICS_TEST=true` to see detailed output showing which metrics are searched and the actual matching lines from the Prometheus endpoint:
151+
152+
```bash
153+
# With wrapper script
154+
VERBOSE_METRICS_TEST=true ./test/run-metrics-tests.sh
155+
156+
# With Docker Compose
157+
VERBOSE_METRICS_TEST=true docker compose run --rm \
158+
-e VERBOSE_METRICS_TEST \
159+
influxdb3-core-pytest \
160+
test/influxdb3/metrics_endpoint_test.py
161+
```
162+
163+
Example verbose output:
164+
```
165+
TEST: HTTP/gRPC Metrics
166+
================================================================================
167+
168+
✓ Searching for: http_requests_total
169+
Found 12 total occurrences
170+
Matches:
171+
# HELP http_requests_total accumulated total requests
172+
# TYPE http_requests_total counter
173+
http_requests_total{method="GET",path="/metrics",status="aborted"} 0
174+
```
175+
176+
#### Phase 2: Prometheus Integration Testing
177+
178+
The `test/influxdb3/prometheus_integration_test.py` suite validates that Prometheus can scrape InfluxDB metrics and that the documented relabeling configuration works correctly.
179+
180+
**What it validates:**
181+
- Prometheus service discovers InfluxDB targets
182+
- Scrape configuration works with authentication
183+
- Relabeling adds `node_name` and `node_role` labels correctly
184+
- Regex patterns in relabel_configs match documentation
185+
- PromQL queries using relabeled metrics work
186+
- Example queries from documentation execute successfully
187+
188+
**Basic Usage:**
189+
190+
```bash
191+
# Using the wrapper script (recommended)
192+
./test/run-metrics-tests.sh --prometheus
193+
194+
# Run both direct and Prometheus tests
195+
./test/run-metrics-tests.sh --all
196+
197+
# Direct execution
198+
./test/influxdb3/run-prometheus-tests.sh
199+
200+
# With verbose output
201+
VERBOSE_PROMETHEUS_TEST=true ./test/influxdb3/run-prometheus-tests.sh
202+
```
203+
204+
**What happens during Prometheus tests:**
205+
206+
1. Starts Prometheus service with documented configuration from `test/influxdb3/prometheus.yml`
207+
2. Waits for Prometheus to discover and scrape both InfluxDB instances
208+
3. Validates relabeling adds `node_name` label (extracted from `__address__`)
209+
4. Validates relabeling adds `node_role` label (based on node name pattern)
210+
5. Tests PromQL queries can filter by node labels
211+
6. Validates example rate() and histogram_quantile() queries work
212+
213+
**Prerequisites:**
214+
- All Phase 1 prerequisites (see below)
215+
- Prometheus service enabled with: `docker compose --profile monitoring up -d`
216+
217+
#### Authentication
218+
219+
Tests require authentication tokens for InfluxDB 3 instances. Store tokens in:
220+
- `~/.env.influxdb3-core-admin-token` (for Core)
221+
- `~/.env.influxdb3-enterprise-admin-token` (for Enterprise)
222+
223+
Or set environment variables directly:
224+
- `INFLUXDB3_CORE_TOKEN`
225+
- `INFLUXDB3_ENTERPRISE_TOKEN`
226+
227+
#### Prerequisites
228+
229+
- Docker and Docker Compose installed
230+
- Running InfluxDB 3 Core container (`influxdb3-core:8181`)
231+
- Running InfluxDB 3 Enterprise container (`influxdb3-enterprise:8181`)
232+
- Valid authentication tokens
233+
- For Phase 2: Prometheus service (`docker compose --profile monitoring up -d`)
234+
124235
## Link Validation with Link-Checker
125236

126237
Link validation uses the `link-checker` tool to validate internal and external links in documentation files.

compose.yaml

Lines changed: 111 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ services:
306306
working_dir: /app
307307
influxdb3-core:
308308
container_name: influxdb3-core
309-
image: influxdb:3-core
310-
pull_policy: always
309+
image: influxdb:3.5.0-core-arm64
310+
pull_policy: never
311311
# Set variables (except your auth token) for Core in the .env.3core file.
312312
env_file:
313313
- .env.3core
@@ -338,8 +338,8 @@ services:
338338
- influxdb3-core-admin-token
339339
influxdb3-enterprise:
340340
container_name: influxdb3-enterprise
341-
image: influxdb:3-enterprise
342-
pull_policy: always
341+
image: influxdb:3.5.0-enterprise-arm64
342+
pull_policy: never
343343
# Set license email and other variables (except your auth token) for Enterprise in the .env.3ent file.
344344
env_file:
345345
- .env.3ent
@@ -369,6 +369,74 @@ services:
369369
target: /var/lib/influxdb3/plugins/custom
370370
secrets:
371371
- influxdb3-enterprise-admin-token
372+
influxdb3-enterprise-write:
373+
container_name: influxdb3-enterprise-write
374+
image: influxdb:3.5.0-enterprise-arm64
375+
pull_policy: never
376+
# Set license email and other variables (except your auth token) for Enterprise in the .env.3ent file.
377+
env_file:
378+
- .env.3ent
379+
ports:
380+
- 8183:8181
381+
command:
382+
- influxdb3
383+
- serve
384+
- --node-id=writer-0
385+
- --mode=ingest
386+
- --cluster-id=cluster0
387+
- --object-store=file
388+
- --data-dir=/var/lib/influxdb3/data
389+
- --plugin-dir=/var/lib/influxdb3/plugins
390+
- --log-filter=debug
391+
- --verbose
392+
environment:
393+
- INFLUXDB3_AUTH_TOKEN=/run/secrets/influxdb3-enterprise-admin-token
394+
volumes:
395+
- type: bind
396+
source: test/.influxdb3/enterprise/data
397+
target: /var/lib/influxdb3/data
398+
- type: bind
399+
source: test/.influxdb3/plugins/influxdata
400+
target: /var/lib/influxdb3/plugins
401+
- type: bind
402+
source: test/.influxdb3/enterprise/plugins
403+
target: /var/lib/influxdb3/plugins/custom
404+
secrets:
405+
- influxdb3-enterprise-admin-token
406+
influxdb3-enterprise-query:
407+
container_name: influxdb3-enterprise-query
408+
image: influxdb:3.5.0-enterprise-arm64
409+
pull_policy: never
410+
# Set license email and other variables (except your auth token) for Enterprise in the .env.3ent file.
411+
env_file:
412+
- .env.3ent
413+
ports:
414+
- 8184:8181
415+
command:
416+
- influxdb3
417+
- serve
418+
- --node-id=querier-0
419+
- --mode=query
420+
- --cluster-id=cluster0
421+
- --object-store=file
422+
- --data-dir=/var/lib/influxdb3/data
423+
- --plugin-dir=/var/lib/influxdb3/plugins
424+
- --log-filter=debug
425+
- --verbose
426+
environment:
427+
- INFLUXDB3_AUTH_TOKEN=/run/secrets/influxdb3-enterprise-admin-token
428+
volumes:
429+
- type: bind
430+
source: test/.influxdb3/enterprise/data
431+
target: /var/lib/influxdb3/data
432+
- type: bind
433+
source: test/.influxdb3/plugins/influxdata
434+
target: /var/lib/influxdb3/plugins
435+
- type: bind
436+
source: test/.influxdb3/enterprise/plugins
437+
target: /var/lib/influxdb3/plugins/custom
438+
secrets:
439+
- influxdb3-enterprise-admin-token
372440
telegraf-pytest:
373441
container_name: telegraf-pytest
374442
image: influxdata/docs-pytest
@@ -499,7 +567,7 @@ services:
499567
remark-lint:
500568
container_name: remark-lint
501569
build:
502-
context: .
570+
context: .
503571
dockerfile: .ci/Dockerfile.remark
504572
profiles:
505573
- lint
@@ -510,11 +578,48 @@ services:
510578
- type: bind
511579
source: ./CONTRIBUTING.md
512580
target: /app/CONTRIBUTING.md
581+
prometheus:
582+
container_name: prometheus
583+
image: prom/prometheus:latest
584+
ports:
585+
- "9090:9090"
586+
environment:
587+
- INFLUXDB3_CORE_TOKEN=${INFLUXDB3_CORE_TOKEN}
588+
- INFLUXDB3_ENTERPRISE_TOKEN=${INFLUXDB3_ENTERPRISE_TOKEN}
589+
volumes:
590+
- type: bind
591+
source: ./test/influxdb3/prometheus.yml
592+
target: /etc/prometheus/prometheus.yml
593+
read_only: true
594+
- type: volume
595+
source: prometheus-data
596+
target: /prometheus
597+
entrypoint:
598+
- /bin/sh
599+
- -c
600+
- |
601+
echo "$$INFLUXDB3_CORE_TOKEN" > /tmp/core-token
602+
echo "$$INFLUXDB3_ENTERPRISE_TOKEN" > /tmp/enterprise-token
603+
exec /bin/prometheus \
604+
--config.file=/etc/prometheus/prometheus.yml \
605+
--storage.tsdb.path=/prometheus \
606+
--web.console.libraries=/usr/share/prometheus/console_libraries \
607+
--web.console.templates=/usr/share/prometheus/consoles \
608+
--web.enable-lifecycle
609+
depends_on:
610+
- influxdb3-core
611+
- influxdb3-enterprise
612+
profiles:
613+
- monitoring
513614
volumes:
514615
test-content:
515616
cloud-tmp:
516617
cloud-dedicated-tmp:
517618
cloud-serverless-tmp:
518619
clustered-tmp:
519620
telegraf-tmp:
520-
v2-tmp:
621+
v2-tmp:
622+
influxdb3-core-tmp:
623+
influxdb2-data:
624+
influxdb2-config:
625+
prometheus-data:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: Monitor metrics
3+
seotitle: Monitor InfluxDB 3 Core metrics
4+
description: >
5+
Access and understand Prometheus-format metrics exposed by {{< product-name >}}
6+
to monitor system performance, resource usage, and operational health.
7+
menu:
8+
influxdb3_core:
9+
parent: Administer InfluxDB
10+
name: Monitor metrics
11+
weight: 110
12+
influxdb3/core/tags: [monitoring, metrics, prometheus, observability, operations]
13+
related:
14+
- /influxdb3/core/reference/internals/runtime-architecture/
15+
- /influxdb3/core/admin/performance-tuning/
16+
- /influxdb3/core/plugins/library/, InfluxDB 3 Core plugins
17+
- /influxdb3/core/write-data/use-telegraf/
18+
- /influxdb3/core/reference/telemetry/
19+
source: /shared/influxdb3-admin/monitor-metrics.md
20+
---
21+
22+
<!--
23+
//SOURCE - content/shared/influxdb3-admin/monitor-metrics.md
24+
-->
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: Metrics
3+
seotitle: InfluxDB 3 Core metrics reference
4+
description: >
5+
InfluxDB 3 Core exposes Prometheus-format metrics,
6+
including descriptions, types, and labels for monitoring and observability.
7+
menu:
8+
influxdb3_core:
9+
parent: Reference
10+
weight: 106
11+
influxdb3/core/tags: [metrics, prometheus, monitoring, reference, observability]
12+
related:
13+
- /influxdb3/core/admin/monitor-metrics/
14+
- /influxdb3/core/reference/telemetry/
15+
- /influxdb3/core/reference/internals/runtime-architecture/
16+
source: /shared/influxdb3-reference/metrics.md
17+
---
18+
19+
<!--
20+
The content of this file is located at
21+
//SOURCE - content/shared/influxdb3-reference/metrics.md
22+
-->

content/influxdb3/enterprise/admin/last-value-cache/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: >
99
menu:
1010
influxdb3_enterprise:
1111
parent: Administer InfluxDB
12-
weight: 105
12+
weight: 106
1313
influxdb3/enterprise/tags: [cache]
1414
related:
1515
- /influxdb3/enterprise/reference/sql/functions/cache/#last_cache, last_cache SQL function
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: Monitor metrics
3+
seotitle: Monitor {{< product-name >}} metrics
4+
description: >
5+
Access and understand Prometheus-format metrics exposed by {{< product-name >}}
6+
to monitor distributed cluster performance, resource usage, and operational health.
7+
menu:
8+
influxdb3_enterprise:
9+
parent: Administer InfluxDB
10+
name: Monitor metrics
11+
weight: 110
12+
influxdb3/enterprise/tags: [monitoring, metrics, prometheus, observability, operations, clustering]
13+
related:
14+
- /influxdb3/enterprise/admin/clustering/
15+
- /influxdb3/enterprise/reference/internals/runtime-architecture/
16+
- /influxdb3/enterprise/admin/performance-tuning/
17+
- /influxdb3/enterprise/plugins/library/, InfluxDB 3 Enterprise plugins
18+
- /influxdb3/enterprise/write-data/use-telegraf/
19+
- /influxdb3/enterprise/reference/telemetry/
20+
source: /shared/influxdb3-admin/monitor-metrics.md
21+
---
22+
23+
<!--
24+
The content of this file is located at
25+
//SOURCE - content/shared/influxdb3-admin/monitor-metrics.md
26+
-->

0 commit comments

Comments
 (0)