-
Notifications
You must be signed in to change notification settings - Fork 36
Add InfluxDB importer #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Gerrrr
merged 5 commits into
apache:master
from
adambernier:add-influxdb-importer-clean
Aug 24, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9211bd5
Add InfluxDB importer
adambernier 2ac165c
Fix InfluxDB query escaping and timestamps
adambernier 770c065
Add reproducible InfluxDB example and E2E test
adambernier 611de52
Stabilize InfluxDB missing column errors
adambernier 7c47ab5
Test InfluxDB analysis through CLI
adambernier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one | ||
| or more contributor license agreements. See the NOTICE file | ||
| distributed with this work for additional information | ||
| regarding copyright ownership. The ASF licenses this file | ||
| to you under the Apache License, Version 2.0 (the | ||
| "License"); you may not use this file except in compliance | ||
| with the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, | ||
| software distributed under the License is distributed on an | ||
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| KIND, either express or implied. See the License for the | ||
| specific language governing permissions and limitations | ||
| under the License. | ||
| --> | ||
|
|
||
| # Importing results from InfluxDB 3 | ||
|
|
||
| Otava imports query results from InfluxDB 3 Core or Enterprise through the | ||
| [`influxdb3-python`](https://docs.influxdata.com/influxdb3/core/reference/client-libraries/v3/python/) | ||
| client. SQL is the default query language; set `query_language: influxql` for | ||
| InfluxQL queries. | ||
|
|
||
| ## Connection | ||
|
|
||
| ```yaml | ||
| influxdb: | ||
| host: http://localhost:8181 | ||
| database: performance | ||
| token: ${INFLUXDB_TOKEN} | ||
| ``` | ||
|
|
||
| The same settings are available through `INFLUXDB_HOST`, `INFLUXDB_DATABASE`, | ||
| and `INFLUXDB_TOKEN`, or the `--influxdb-host`, `--influxdb-database`, and | ||
| `--influxdb-token` command-line options. Command-line values take precedence | ||
| over environment variables, which take precedence over YAML. | ||
|
|
||
| ## Reproducible example | ||
|
|
||
| The bundled example starts InfluxDB 3 Core with authenticated, in-memory | ||
| storage, seeds deterministic latency data, and runs Otava against it: | ||
|
|
||
| ```bash | ||
| docker build -t apache/otava:latest . | ||
| docker compose -f examples/influxdb/docker-compose.yaml run --rm otava \ | ||
| analyze api_latency_sql --branch main --since 2025-01-01 | ||
| docker compose -f examples/influxdb/docker-compose.yaml down | ||
| ``` | ||
|
|
||
| Run `api_latency_influxql` instead to query the same data with InfluxQL. | ||
|
|
||
| The admin token committed under `examples/influxdb/` is a fixed test | ||
| credential, and the server discards its in-memory data when stopped. Both are | ||
| for this local demonstration only. Use a securely generated token and durable | ||
| object storage for production deployments. | ||
|
|
||
| ## Test configuration | ||
|
|
||
| ```yaml | ||
| tests: | ||
| api_latency_sql: | ||
| type: influxdb | ||
| query_language: sql | ||
| query: | | ||
| SELECT time, branch, p95_ms, commit | ||
| FROM api_latency | ||
| WHERE branch = %{BRANCH} | ||
| ORDER BY time | ||
| time_column: time | ||
| attributes: [branch, commit] | ||
| metrics: | ||
| p95: | ||
| column: p95_ms | ||
| direction: -1 | ||
| scale: 1 | ||
|
|
||
| legacy_api_latency: | ||
| type: influxdb | ||
| query_language: influxql | ||
| query: SELECT time, branch, p95_ms FROM api_latency WHERE branch = %{BRANCH} | ||
| attributes: [branch] | ||
| metrics: [p95_ms] | ||
| ``` | ||
|
|
||
| Metric definitions use `column`, `direction`, and `scale` as with the other | ||
| SQL-backed importers. `%{BRANCH}` is replaced with an escaped string literal | ||
| when `--branch` is supplied. | ||
|
|
||
| Run the analysis with: | ||
|
|
||
| ```bash | ||
| otava analyze api_latency_sql --branch main --last 100 | ||
| ``` | ||
|
|
||
| InfluxDB is import-only in this release; Otava does not write change points | ||
| back to InfluxDB. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "token": "apiv3_otava_example_admin_token_2026", | ||
| "name": "otava-example-admin", | ||
| "description": "Test-only admin token for the reproducible Otava example" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| api_latency,branch=main,commit=a1b2c3d p95_ms=87.0 1735689600000000000 | ||
| api_latency,branch=release,commit=r1e2l3s p95_ms=105.0 1735689600000000000 | ||
| api_latency,branch=main,commit=b2c3d4e p95_ms=85.0 1735776000000000000 | ||
| api_latency,branch=main,commit=c3d4e5f p95_ms=89.0 1735862400000000000 | ||
| api_latency,branch=main,commit=d4e5f6a p95_ms=118.0 1735948800000000000 | ||
| api_latency,branch=main,commit=e5f6a7b p95_ms=121.0 1736035200000000000 | ||
| api_latency,branch=main,commit=f6a7b8c p95_ms=119.0 1736121600000000000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| services: | ||
| influxdb: | ||
| image: influxdb:3.11.2-core | ||
| command: | ||
| - influxdb3 | ||
| - serve | ||
| - --node-id=otava-example | ||
| - --object-store=memory | ||
| - --admin-token-file=/run/secrets/admin-token | ||
| ports: | ||
| - "8181:8181" | ||
| secrets: | ||
| - admin-token | ||
|
|
||
| seed: | ||
| image: influxdb:3.11.2-core | ||
| entrypoint: ["/bin/sh", "/example/seed.sh"] | ||
| depends_on: | ||
| - influxdb | ||
| environment: | ||
| INFLUXDB3_AUTH_TOKEN: apiv3_otava_example_admin_token_2026 | ||
| INFLUXDB3_DATABASE_NAME: performance | ||
| INFLUXDB3_HOST_URL: http://influxdb:8181 | ||
| volumes: | ||
| - .:/example:ro | ||
|
|
||
| otava: | ||
| image: apache/otava:latest | ||
| depends_on: | ||
| seed: | ||
| condition: service_completed_successfully | ||
| environment: | ||
| INFLUXDB_HOST: http://influxdb:8181 | ||
| INFLUXDB_DATABASE: performance | ||
| INFLUXDB_TOKEN: apiv3_otava_example_admin_token_2026 | ||
| OTAVA_CONFIG: /config/otava.yaml | ||
| volumes: | ||
| - ./otava.yaml:/config/otava.yaml:ro | ||
|
|
||
| secrets: | ||
| admin-token: | ||
| file: ./admin-token.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| # InfluxDB 3 connection settings can also be supplied with INFLUXDB_HOST, | ||
|
Gerrrr marked this conversation as resolved.
|
||
| # INFLUXDB_DATABASE, and INFLUXDB_TOKEN. | ||
| influxdb: | ||
| host: http://localhost:8181 | ||
| database: performance | ||
| token: ${INFLUXDB_TOKEN} | ||
|
|
||
| tests: | ||
| api_latency_sql: | ||
| type: influxdb | ||
| query_language: sql | ||
| query: | | ||
| SELECT time, branch, p95_ms, commit | ||
| FROM api_latency | ||
| WHERE branch = %{BRANCH} | ||
| ORDER BY time | ||
| time_column: time | ||
| attributes: [branch, commit] | ||
| metrics: | ||
| p95: | ||
| column: p95_ms | ||
| direction: -1 | ||
| scale: 1 | ||
|
|
||
| api_latency_influxql: | ||
| type: influxdb | ||
| query_language: influxql | ||
| query: | | ||
| SELECT time, branch, commit, p95_ms | ||
| FROM api_latency | ||
| WHERE branch = %{BRANCH} | ||
| ORDER BY time | ||
| time_column: time | ||
| attributes: [branch, commit] | ||
| metrics: | ||
| p95: | ||
| column: p95_ms | ||
| direction: -1 | ||
| scale: 1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #!/bin/sh | ||
|
|
||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| set -eu | ||
|
|
||
| : "${INFLUXDB3_AUTH_TOKEN:?INFLUXDB3_AUTH_TOKEN must be set}" | ||
|
|
||
| INFLUXDB3_HOST_URL="${INFLUXDB3_HOST_URL:-http://influxdb:8181}" | ||
| INFLUXDB3_DATABASE_NAME="${INFLUXDB3_DATABASE_NAME:-performance}" | ||
| SEED_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) | ||
|
|
||
| export INFLUXDB3_HOST_URL INFLUXDB3_DATABASE_NAME | ||
|
|
||
| attempt=0 | ||
| until influxdb3 show databases --format csv >/dev/null 2>&1; do | ||
| attempt=$((attempt + 1)) | ||
| if [ "$attempt" -ge 60 ]; then | ||
| echo "InfluxDB did not become ready at $INFLUXDB3_HOST_URL" >&2 | ||
| exit 1 | ||
| fi | ||
| sleep 1 | ||
| done | ||
|
|
||
| if ! influxdb3 show databases --format csv | grep -Fqx "$INFLUXDB3_DATABASE_NAME"; then | ||
| influxdb3 create database "$INFLUXDB3_DATABASE_NAME" | ||
| fi | ||
|
|
||
| influxdb3 write \ | ||
| --database "$INFLUXDB3_DATABASE_NAME" \ | ||
| --precision ns \ | ||
| --file "$SEED_DIR/data.lp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.