Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Apache Otava – Change Detection for Continuous Performance Engineering


Apache Otava (incubating) performs statistical analysis of performance test results stored
in CSV files, PostgreSQL, BigQuery, or Graphite database. It finds change-points and notifies about
in CSV files, PostgreSQL, BigQuery, InfluxDB 3, or Graphite database. It finds change-points and notifies about
possible performance regressions.

A typical use-case of otava is as follows:
Expand Down
99 changes: 99 additions & 0 deletions docs/INFLUXDB.md
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
Comment thread
Gerrrr marked this conversation as resolved.
```

InfluxDB is import-only in this release; Otava does not write change points
back to InfluxDB.
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
- [PostgreSQL](POSTGRESQL.md)
- [BigQuery](BIG_QUERY.md)
- [CSV](CSV.md)
- [InfluxDB](INFLUXDB.md)
- [Annotating Change Points in Grafana](GRAFANA.md)
5 changes: 5 additions & 0 deletions examples/influxdb/admin-token.json
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"
}
7 changes: 7 additions & 0 deletions examples/influxdb/data.lp
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
59 changes: 59 additions & 0 deletions examples/influxdb/docker-compose.yaml
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
56 changes: 56 additions & 0 deletions examples/influxdb/otava.yaml
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,
Comment thread
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
47 changes: 47 additions & 0 deletions examples/influxdb/seed.sh
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"
5 changes: 5 additions & 0 deletions otava/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from otava.bigquery import BigQueryConfig
from otava.grafana import GrafanaConfig
from otava.graphite import GraphiteConfig
from otava.influxdb import InfluxDBConfig
from otava.postgres import PostgresConfig
from otava.slack import SlackConfig
from otava.test_config import TestConfig, create_test_config
Expand All @@ -40,6 +41,7 @@ class Config:
slack: SlackConfig
postgres: PostgresConfig
bigquery: BigQueryConfig
influxdb: InfluxDBConfig


@dataclass
Expand Down Expand Up @@ -115,6 +117,7 @@ def load_config_from_parser_args(args: configargparse.Namespace) -> Config:
slack=SlackConfig.from_parser_args(args),
postgres=PostgresConfig.from_parser_args(args),
bigquery=BigQueryConfig.from_parser_args(args),
influxdb=InfluxDBConfig.from_parser_args(args),
tests=tests,
test_groups=groups,
)
Expand All @@ -133,6 +136,7 @@ class NestedYAMLConfigFileParser(configargparse.ConfigFileParser):
SlackConfig.NAME,
PostgresConfig.NAME,
BigQueryConfig.NAME,
InfluxDBConfig.NAME,
]

def parse(self, stream):
Expand Down Expand Up @@ -180,6 +184,7 @@ def add_service_option_groups(parser) -> None:
SlackConfig.add_parser_args(parser.add_argument_group('Slack Options', 'Options for Slack configuration'))
PostgresConfig.add_parser_args(parser.add_argument_group('PostgreSQL Options', 'Options for PostgreSQL configuration'))
BigQueryConfig.add_parser_args(parser.add_argument_group('BigQuery Options', 'Options for BigQuery configuration'))
InfluxDBConfig.add_parser_args(parser.add_argument_group('InfluxDB Options', 'Options for InfluxDB 3 configuration'))


def argument_group(parser, title: str):
Expand Down
Loading
Loading