Reporting using API
Let's suppose you want to integrate reporting into a CI process, or you want to create a button in Grafana. 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
- output_id: ID 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": "..."
},
{
"test_title": "...",
"template_id": "...",
"baseline_test_title": "..."
}
],
"influxdb_id": "...",
"output_id": "...",
"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, influxdb_id and output_id.
curl -k --fail-with-body --request POST \
--url http://1.1.1.1:7878/generate
-H "Content-Type: application/json" \
-H "Cookie: project=bb40155d-d94c-48e5-9bc9-f0caa26db11f" \
--data '{
"tests": [
{
"test_title": "20230211-1106-demo",
"template_id": "b8022508-a4b0-411b-bf82-38865c296fb6"
}
],
"influxdb_id": "3ab101ed-cefc-493a-8bce-1db687b7da7a",
"output_id": "c0580a52-29d4-47e8-aabf-906190a604a1"
}'
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://1.1.1.1:7878/generate
-H "Content-Type: application/json" \
-H "Cookie: project=bb40155d-d94c-48e5-9bc9-f0caa26db11f" \
--data '{
"tests": [
{
"test_title": "20230211-1106-demo",
"template_id": "b8022508-a4b0-411b-bf82-38865c296fb6"
},
{
"test_title": "20240211-1408-demo",
"template_id": "e6da01eb-889c-4b40-a19c-83654a4e4b69"
}
],
"influxdb_id": "3ab101ed-cefc-493a-8bce-1db687b7da7a",
"output_id": "c0580a52-29d4-47e8-aabf-906190a604a1",
"template_group": "e1a82b68-ac80-41ff-87a1-c575c2690f92"
}'
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://1.1.1.1:7878/generate
-H "Content-Type: application/json" \
-H "Cookie: project=bb40155d-d94c-48e5-9bc9-f0caa26db11f" \
--data '{
"tests": [
{
"test_title": "20230211-1106-demo",
"template_id": "b8022508-a4b0-411b-bf82-38865c296fb6",
"baseline_test_title": "20240211-1408-demo"
}
],
"influxdb_id": "3ab101ed-cefc-493a-8bce-1db687b7da7a",
"output_id": "c0580a52-29d4-47e8-aabf-906190a604a1"
}'