Elasticsearch plugin
Overview
The Elasticsearch plugin connects QALIPSIS to Elasticsearch using the elasticsearch REST client.
Elasticsearch allows QALIPSIS to poll, search, save, and analyze data from your tested system.
This page explains configuration, core concepts, secure connection options, runnable examples and best practices.
- Technology addressed
-
Elasticsearch: https://www.elastic.co/
- Dependency
-
io.qalipsis.plugin:qalipsis-plugin-elasticsearch - Namespace in scenario
-
elasticsearch() - Client library
-
JAVA API: refer to Elasticsearch JAVA Client.
Supported steps
Poll step
The poll step within the Elasticsearch plugin reads batches of documents periodically from Elasticsearch.
The output is a list of ElasticsearchDocument containing JSON data or deserialized to objects.
- Ancestor
-
Scenario
- Functionality
-
-
The
pollstep is created only once in a scenario; it is then used throughout the scenario as called. -
The
pollstep within the Elasticsearch plugin uses a strategy of “delivered exactly once”. -
The output of the
pollstep is anElasticsearchDocumentthat contains maps of column to values.
-
- Example
elasticsearch().poll { (1)
name = "my-poll-step"
client { RestClient.builder(HttpHost.create("http://localhost:9200")).build() } (2)
query { (3)
"""{
"query":{
"match_all":{}
},
"sort" : ["_score"]
}""".trimIndent()
}
index("battery-state") (4)
pollDelay(Duration.ofSeconds(1)) (5)
}
<1> Start the `poll` step. <2> Configure the REST client connection. <3> Configure the query. <4> Set the `elasticsearch` index to use for the queries. <5> Specify the delay between query executions.
- Tips
-
-
The
pollstep is generally used in conjunction with ajointo assert data or inject data into a workflow. -
The
queryparameter requires at least one sorting field to filter the newest results and not fetch the same records repeatedly. -
The output of the
pollstep is anElasticsearchDocumentthat contains maps of column names to values. Ifflattenis called, the records are provided one by one to the next step; otherwise each poll batch remains complete.
-
- Reference Documentation
-
-
Refer to Elasticsearch Query Parameters for more information on query parameters.
-
Refer to the Elasticsearch documentation for further parameter and configuration information.
-
Save step
The save step within the Elasticsearch plugin persists a batch of documents into Elasticsearch.
- Ancestor
-
Step
- Functionality
-
The
savestep’s input and step context are used to generate a list of documents that are forwarded to Elasticsearch. - Example
previousStep.elasticsearch().save { (1)
name = "my-save-step" (2)
client { (3)
RestClient.builder(HttpHost.create("http://localhost:9200"))
.build()
}
documents { stepContext, input -> (4)
listOf(
Document(
index = "battery-state",
id = input.deviceId,
source = objectMapper.writeValueAsString(input)
)
)
}
}
| 1 | Start the save step.
Note: previousStep is a placeholder for any preceding step (e.g. collect() etc.). |
| 2 | Give a name to the step. |
| 3 | Configure the REST client connection. |
| 4 | Define the strategy to create documents to save using the step context and input. |
- Reference Documentation
-
Refer to the Elasticsearch documentation for further parameter information.
Search step
The search step within the Elasticsearch plugin searches documents in the Elasticsearch 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
previousStep.elasticsearch().search { (1)
name = "my-search-step"
client { (2)
RestClient.builder(HttpHost.create("http://localhost:9200")).build()
}
index { stepContext, input -> listOf("battery-state") } (3)
query { stepContext, input -> (4)
"""{
"query": {
"bool": {
"must": [
{ "match": { "deviceId": "${input.input.deviceId}" }},
{ "term": { "timestamp": ${input.input.timestamp.epochSecond} }}
]
}
}
}"""
}
}
| 1 | Start the search step.
Note: previousStep is a placeholder for any preceding step (e.g. collect() etc.) |
| 2 | Configure the REST client connection. |
| 3 | Set the elasticsearch indices to use for the queries, resolved from the step context and input. |
| 4 | Configure the builder for the JSON query to perform a search, resolved from the step context and input. |
- Reference Documentation
-
-
Refer to the Elasticsearch documentation for further parameter and configuration information.
-
For specifics on
queryParametersrefer to Elasticsearch Query Parameters. -
For specifics on
searchparameters, refer to Elasticsearch Search Parameters.
-
Configuration
DSL parameters
Available parameters are described in the table below.
| Parameter | Description |
|---|---|
|
Configures the REST client to connect to Elasticsearch Example
|
|
Sets the elasticsearch indices to use for the queries. Example (Poll)
Example (Search)
|
|
Configures the builder for the JSON query to perform the poll/search. Example (Poll)
Example (Search)
|
|
Adds parameters to the query. Example (Poll)
Example (Search)
|
|
Specifies the delay between two successive polls. Example
|
|
Configures how polled results are delivered to scenario minions. |
|
Builds the list of documents to save using the Elasticsearch Bulk API. Example
|
|
Configures QALIPSIS monitoring (meters/events) for the step. |
|
When called, keeps the response from Elasticsearch after saving documents and forwards it to the next step. Example
|
|
Fetches all results from Elasticsearch, even if over the result-sized window. Example
|
|
Configures the JSON mapper to use for deserializing JSON documents from Elasticsearch into objects. Example
|
Shared defaults for Elasticsearch steps
You can define defaults once in the scenario section or just after, and let all following Elasticsearch steps inherit them.
scenario {
elasticsearch().defaults { (1)
client {
RestClient.builder(HttpHost.create("http://localhost:9200")).build()
}
monitoring {
events = true
meters = true
}
}
}
| 1 | Defaults are applied to subsequent Elasticsearch steps in the same scenario. Individual steps can still override values. |
Analytics
QALIPSIS can publish the meters and events collected during a campaign to Elasticsearch 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 documents to time‑partitioned Elasticsearch indices.
meters:
export:
elasticsearch:
enabled: true
urls:
- http://localhost:9200
path-prefix: /
index-prefix: qalipsis-meters
refresh-interval: 10s
store-source: true
index-date-pattern: yyyy-MM-dd
publishers: 1
username:
password:
shards: 1
replicas: 0
proxy:
The parameters used to configure the publication of meters to Elasticsearch are described in the table below.
| Parameter | Description |
|---|---|
|
Activates the publication of meters to Elasticsearch. Must be set to |
|
List of URLs to the Elasticsearch instances. |
|
Prefix prepended to the URL paths sent to Elasticsearch. |
|
Prefix used for the created indices that contain the meters. |
|
Delay between two refreshes of the meter indices in Elasticsearch. |
|
Stores the |
|
Pattern of the date suffix appended to the index name to generate time‑partitioned indices, as supported by |
|
Number of concurrent publishers that can send meter batches to Elasticsearch. |
|
Name of the user for basic authentication when connecting to Elasticsearch. |
|
Password of the user for basic authentication when connecting to Elasticsearch. |
|
Number of shards applied to the created meter indices. |
|
Number of replicas applied to the created meter indices. |
|
URL of the HTTP proxy to use to access Elasticsearch. Useful when an alternative authentication mechanism is required to reach the cluster. |
Events
The events publisher buffers the events emitted during a campaign and writes them in bulk as documents to time‑partitioned Elasticsearch indices.
events:
export:
elasticsearch:
enabled: true
min-level: INFO
urls:
- http://localhost:9200
path-prefix: /
index-prefix: qalipsis-events
refresh-interval: 10s
store-source: true
index-date-pattern: yyyy-MM-dd
linger-period: 10s
batch-size: 40000
publishers: 1
username:
password:
shards: 1
replicas: 0
proxy:
The parameters used to configure the publication of events to Elasticsearch are described in the table below.
| Parameter | Description |
|---|---|
|
Activates the publication of events to Elasticsearch. Must be set to |
|
Minimum event level published. Acceptable values are |
|
List of URLs to the Elasticsearch instances. |
|
Prefix prepended to the URL paths sent to Elasticsearch. |
|
Prefix used for the created indices that contain the events. |
|
Delay between two refreshes of the event indices in Elasticsearch. |
|
Stores the |
|
Pattern of the date suffix appended to the index name to generate time‑partitioned indices, as supported by |
|
Maximum time the events are buffered before forcing a flush to Elasticsearch, even when the batch size is not reached. |
|
Maximum number of events buffered between two publications to Elasticsearch before flushing a bulk request. |
|
Number of concurrent publishers that can send event batches to Elasticsearch. |
|
Name of the user for basic authentication when connecting to Elasticsearch. |
|
Password of the user for basic authentication when connecting to Elasticsearch. |
|
Number of shards applied to the created event indices. |
|
Number of replicas applied to the created event indices. |
|
URL of the HTTP proxy to use to access Elasticsearch. Useful when an alternative authentication mechanism is required to reach the cluster. |
- Reference Documentation
-
Refer to Monitoring test campaigns for a further explanation of the meter and event parameter values.