Reporting using API
Let's suppose you want to integrate reporting into a CI process, in such cases, an API can be used to initiate the generation of the report.
API request body overview​
- tests: represents a list of tests for which the report should be generated
- test_title: points to a particular test, and it should align with the one in InfluxDB
- template_id: ID of configured template
- baseline_test_title: optional parameter and should be used when a comparison is needed, it indicates the baseline test title
- db_config (id, source_type): ID and source type of configured InfluxDB integration
- output_config (output_id, integration_type): ID and integration type of configured output integration
- template_group: optional ID parameter, if you need to generate a report for several tests
{
"tests": [
{
"test_title": "...",
"template_id": "...",
"baseline_test_title": "...",
"db_config":{
"id":"...",
"source_type":"influxdb_v2"
}
},
{
"test_title": "...",
"template_id": "...",
"baseline_test_title": "...",
"db_config":{
"id":"...",
"source_type":"influxdb_v2"
}
}
],
"output_config": {
"output_id":"...",
"integration_type": "..."
},
"template_group": "..."
}
Below, you can find several examples.
Hint​
To get the ID for integrations and templates, as well as if you are not sure how to properly configure the API request, go to the "Tests" tab. There, select all the necessary parameters and click the "Show API" button. In this case, the appropriate curl format will be displayed to create a report with the necessary ids.
Without template group​
To start the report generation process, we'll need to provide the test_title, template_id, db_config and output_config.
curl -k --fail-with-body --request POST \
--url http://localhost:7878/api/v1/reports \
-H "Content-Type: application/json" \
-H "Cookie: project=2" \
--data '{
"tests": [
{
"test_title": "20240919-1543-DEMO_good",
"template_id": "18",
"db_config": {
"id": 4,
"source_type": "influxdb_v2"
}
}
],
"output_config": {
"output_id": "pdf_report",
"theme": "dark"
}
}'
With template group​
If you're planning to generate reports for multiple tests using a template group, you will also need to pass template_group.
curl -k --fail-with-body --request POST \
--url http://localhost:7878/api/v1/reports \
-H "Content-Type: application/json" \
-H "Cookie: project=2" \
--data '{
"tests": [
{
"test_title": "20240919-1543-DEMO_good",
"template_id": "17",
"db_config": {
"id": 4,
"source_type": "influxdb_v2"
}
},
{
"test_title": "20240712-0452-DEMO_bad_spike",
"template_id": "20",
"db_config": {
"id": 4,
"source_type": "influxdb_v2"
}
}
],
"output_config": {
"output_id": 2,
"integration_type": "azure_wiki"
},
"template_group": "2"
}'
With comparison​
If you plan to use a baseline for comparison, you'll need to provide the baseline_test_title parameter.
curl -k --fail-with-body --request POST \
--url http://localhost:7878/api/v1/reports \
-H "Content-Type: application/json" \
-H "Cookie: project=2" \
--data '{
"tests": [
{
"test_title": "20240919-1543-DEMO_good",
"template_id": "18",
"db_config": {
"id": 4,
"source_type": "influxdb_v2"
},
"baseline_test_title": "20240712-0452-DEMO_bad_spike"
}
],
"output_config": {
"output_id": "pdf_report",
"theme": "dark"
}
}'