InfluxDB plugin
Overview
The InfluxDB plugin connects QALIPSIS to InfluxDB.
- Technologies addressed
-
-
InfluxDB: https://www.influxdata.com/
-
- Dependency
-
io.qalipsis.plugin:qalipsis-plugin-influxdb - Namespace in scenario
-
influxdb() - Client library
-
influxdb-client-kotlin: refer to the influxdb-client-kotlin.
Supported steps
Poll step
The poll step within the InfluxDB plugin polls the newest records from the database, with a delay between each execution of a select query.
- Ancestor
-
Scenario
- Functionality
-
The
pollstep is created only once in a scenario; it is then used throughout the scenario as called. Thepollstep within the InfluxDB plugin uses a strategy of “delivered at least once”. - Example
-
influxdb().poll { connect { (1) server( url = "http://localhost:18086", bucket = "iot", org = "qalipsis" ) basic(user = "DJones", password = "Oxford1987") } query( (2) """ from(bucket:"${iot}") |> range(start: -15m) |> filter( fn: (r) => r._measurement == "battery_state" ) """.trimIndent() ) pollDelay(Duration.ofSeconds(1)) }1 Define the connection parameters to InfluxDB. 2 Specify a query respecting the requirements of InfluxDB. - Tip
-
Use the
pollstep with a join operator to verify the values that the tested system saves to the database. - Reference: Documentation
-
Refer to the InfluxDB documentation for further parameter and configuration information.
Save step
The save step within the InfluxDB plugin persists a batch of records into the InfluxDB bucket using a specific points class.
- Ancestor
-
Step
- Functionality
-
The
savestep’s input and step context are used to generate the bucket, the list of points with their measurement, and tags and fields, which are then combined and forwarded to the database. - Example
-
.save { connect { (1) server( url = "http://localhost:18086", bucket = "iot", org = "qalipsis" ) basic(user = "DJones", password = "Oxford1987") } query { (2) bucket = { StepContext, input -> "iot" } organization = { _, _ -> "qalipsis" } points = { _, input -> listOf( Point.measurement("battery_state") .addField("battery_level", input.batteryLevel) .addTag("device_id", input.deviceId) .addTag("timestamp", input.timestamp.epochSecond.toString()) ) } } }1 Define the connection parameters to InfluxDB. 2 Specify a query respecting the requirements of InfluxDB.
- Tips
-
-
Use the
savestep after acollectstep to reduce the number of queries executed onto the database and to reduce the load your scenario generates on the test system. -
The
savestep is extremely flexible: bucket, tags, measurement and fields might depend on the context and input value received from the previous step.
-
- Reference documentation
-
Refer to the InfluxDB documentation for further parameter and configuration information.
Search step
The search step within the InfluxDB plugin searches records in the database using a search query.
- Ancestor
-
Step
- Functionality
-
The
searchstep’s input and step context are used to generate a query; the batch of results is then forwarded to the next step(s). - Example
.influxdb()
.search {
connect { (1)
server(
url = "http://localhost:18086",
bucket = "iot",
org = "qalipsis"
)
basic(user = "DJones", password = "Oxford1987")
}
query { StepContext, input -> (2)
"""
from(bucket: "${iot}")
|> range(start: -15m)
|> filter(
fn: (r) => r._measurement == "${"battery_state"}" and
r.${"device_id"} == "${input.deviceId}" and
r.${"timestamp"} == "${input.timestamp.epochSecond}"
)
""".trimIndent()
}
}
| 1 | Define the connection parameters to InfluxDB. |
| 2 | Specify a query respecting the requirements of InfluxDB. |
- Tip
-
Use the
searchstep after acollectstep to reduce the number of queries executed onto the database and to reduce the load the scenario generates on the test system. - Reference documentation
-
Refer to the InfluxDB documentation for further parameter and configuration information.
Configuration
DSL parameters
Available parameters are described in the table below.
| Parameter | Description |
|---|---|
|
Defines the connection parameters to InfluxDB. Example
|
|
Identifies the server parameters for the connection to InfluxDB. Example
|
|
Identifies the url for the connection to InfluxDB. Example
|
|
Name of the bucket to use; a bucket defines the the highest level of data organization in InfluxDB. Example
|
|
The name of the organization (i.e., workspace) associated with the bucket. Example
|
|
Specifies a query respecting the requirements of InfluxDB. Example (Poll)
Example (Save)
Example (Search)
|
|
Binds values to the clauses of the prepared query. Example
|
|
Specifies the delay between query executions. Example
|
|
Configures how polled results are delivered to scenario minions. |
Shared defaults for InfluxDB steps
You can define defaults once in the scenario section or just after, and let all following InfluxDB steps inherit them.
scenario {
influxdb().defaults { (1)
connect {
server(
url = "http://localhost:8086",
bucket = "iot",
org = "qalipsis"
)
}
monitoring {
events = true
meters = true
}
}
}
| 1 | Defaults are applied to subsequent InfluxDB steps in the same scenario. Individual steps can still override values. |
Analytics
QALIPSIS can publish the meters and events collected during a campaign to InfluxDB through dedicated publishers.
Configure the publishers in the factory configuration, separate from the scenario DSL. Refer to Provide the configuration to QALIPSIS for information about specifying the configuration to QALIPSIS.
Meters
The meters publisher writes the meter snapshots collected during a campaign as records to an InfluxDB bucket.
meters:
export:
influxdb:
enabled: true
url: http://localhost:8086
user-name:
password:
org: qalipsis
bucket: qalipsis-meter
prefix: qalipsis.
publishers: 1
The parameters used to configure the publication of meters to InfluxDB are described in the table below.
| Parameter | Description |
|---|---|
|
Activates the publication of meters to InfluxDB. Must be set to |
|
URL of the InfluxDB instance receiving the meters. |
|
Name of the user used for basic authentication when connecting to InfluxDB. |
|
Password of the user used for basic authentication when connecting to InfluxDB. |
|
Name of the InfluxDB organization to which the meters are written. |
|
Name of the InfluxDB bucket where the meters are written. |
|
Prefix prepended to every metric name when publishing to InfluxDB. |
|
Number of concurrent publishers that can send meter batches to InfluxDB. |
Events
The events publisher buffers the events emitted during a campaign and writes them in bulk as records to an InfluxDB bucket.
events:
export:
influxdb:
enabled: true
url: http://localhost:8086
min-level: INFO
linger-period: 10s
batch-size: 40000
publishers: 1
username:
password:
org: qalipsis
bucket: qalipsis-event
The parameters used to configure the publication of events to InfluxDB are described in the table below.
| Parameter | Description |
|---|---|
|
Activates the publication of events to InfluxDB. Must be set to |
|
URL of the InfluxDB instance receiving the events. |
|
Minimum event level published. Acceptable values are |
|
Maximum time the events are buffered before forcing a flush to InfluxDB, even when the batch size is not reached. |
|
Maximum number of events buffered between two publications to InfluxDB. |
|
Number of concurrent publishers that can send event batches to InfluxDB. |
|
Name of the user used for basic authentication when connecting to InfluxDB. |
|
Password of the user used for basic authentication when connecting to InfluxDB. |
|
Name of the InfluxDB organization to which the events are written. |
|
Name of the InfluxDB bucket where the events are written. |
- Reference Documentation
-
Refer to Monitoring test campaigns for a further explanation of the meter and event parameter values.