Skip to main content
Version: Unreleased

PDF Report Generation

This guide explains how to configure automated PDF reports using the Auto Trigger feature. PDF reports allow you to visualize Elasticsearch query results with charts and deliver them on a schedule.

The schema defines the structure for configuring automated jobs.

Quick Start

To create a PDF report, add toPdf as your output format. The minimum configuration requires linking your data selections to chart entries.

Key principle: The variableName in your chart configuration must exactly match the variableName defined in your data selection.

Minimal Example

{
"$schema": "/api/asyncJobs/schema",
"name": "Daily Call Report",
"description": "PDF report with call duration chart",
"enabled": true,
"metadata": {
"schemaVersion": "2.0.0"
},
"schedule": {
"cron": "0 6 * * *"
},
"type": "user",
"pipeline": {
"sources": [
{
"dataSource": "es",
"variableName": "CallDurationOverTime",
"parameters": [
{ "index": "calls" },
{
"size": 0,
"query": {
"bool": {
"must": [{ "query_string": { "query": "attrs.type:call-end" } }]
}
},
"aggs": {
"agg": {
"date_histogram": {
"field": "@timestamp",
"fixed_interval": "1h"
}
}
}
}
]
}
],
"transform": {
"transformationType": "js",
"codeFunctionReference": ""
},
"output": {
"formats": [
{
"transformationType": "toPdf",
"parameters": {
"pageSize": "A4",
"orientation": "landscape",
"charts": [
{
"variableName": "CallDurationOverTime",
"chartTitle": "Call Duration Over Time"
}
]
}
}
]
},
"delivery": {
"channels": []
}
}
}

PDF-Specific Configuration

Page Settings

SettingOptionsDescription
pageSizeA4, Letter, LegalPage size: A4 (210 × 297 mm), Letter (8.5 × 11"), Legal (8.5 × 14")
orientationportrait, landscapePage orientation: vertical or horizontal

Chart Configuration

PropertyRequiredDescription
variableNameYesMust match exactly the variableName from data selection
chartTitleNoChart title displayed above the visualization
chartTypeNoExplicit visualization type (auto-inferred if omitted)
maxLengthNoMaximum items to display (for list and table types)

Automatic Chart Type Inference

When you omit the chartType property, the system analyzes your data and automatically selects the most appropriate visualization.

Chart Selection by Data Type

CategoryConditionChart
scalarSingle valuevalue
time-seriesNested buckets + nested valuemultipleLine
time-seriesNested buckets onlystackedBar
time-seriesNo nestingtimedateBar
categoricalNested + depth ≥ 2sunburst
categoricalNested + depth < 2list
categoricalNo nesting + ≤ 8 itemsdonut
categoricalNo nesting + > 8 itemslist
tabularTabular datatable
tuple≤ 8 itemsdonut
tuple> 8 itemslist
unknownFallbackvalue

Tip: For most use cases, automatic inference produces optimal results. Only specify chartType explicitly when you need a specific visualization.


Complete Example

A comprehensive example showing a PDF report with multiple data sources, transformations, and delivery.

Complete Example
{
"$schema": "/api/asyncJobs/schema",
"name": "Daily Call Summary",
"description": "Comprehensive daily call metrics report",
"enabled": true,
"metadata": {
"schemaVersion": "2.0.0"
},
"schedule": {
"cron": "0 7 * * *"
},
"type": "user",
"pipeline": {
"sources": [
{
"dataSource": "es",
"variableName": "CallVolume",
"parameters": [
{ "index": "calls" },
{
"size": 0,
"query": {
"bool": {
"must": [{ "query_string": { "query": "attrs.type:call-end" } }]
}
},
"aggs": {
"daily": {
"date_histogram": {
"field": "@timestamp",
"calendar_interval": "day"
},
"aggs": {
"total_duration": { "sum": { "field": "duration" } }
}
}
}
}
]
},
{
"dataSource": "es",
"variableName": "AgentStats",
"parameters": [
{ "index": "calls" },
{
"size": 0,
"query": {
"bool": {
"must": [{ "query_string": { "query": "attrs.type:call-end" } }]
}
},
"aggs": {
"agents": {
"terms": { "field": "attrs.agent" },
"aggs": {
"calls": { "value_count": { "field": "duration" } },
"duration": { "avg": { "field": "duration" } }
}
}
}
}
]
}
],
"transform": {
"transformationType": "js",
"code": "return { callVolume: data[0], agentStats: data[1] };"
},
"output": {
"formats": [
{
"transformationType": "toPdf",
"parameters": {
"pageSize": "A4",
"orientation": "landscape",
"charts": [
{
"variableName": "CallVolume",
"chartTitle": "Daily Call Volume (Last 30 Days)",
"chartType": "timedateBar"
},
{
"variableName": "AgentStats",
"chartTitle": "Top Agents by Call Count",
"chartType": "list",
"maxLength": 10
}
]
}
},
{
"transformationType": "toCsv",
"parameters": {}
}
]
},
"delivery": {
"channels": ["email-reporting-team"]
},
"action": [
{
"type": "saveToEs",
"parameters": {
"stream": "daily-call-reports",
"timestampField": "@timestamp"
}
}
]
}
}

Best Practices

tip

Follow these best practices for creating effective PDF reports:

  1. Use descriptive variable names — Names like CallDurationByHour are clearer than data1

  2. Let inference work for you — Only specify chartType when you need a specific visualization

  3. Match variable names exactly — Copy-paste to avoid typos between data selection and chart config

  4. Use landscape for dashboards — Multiple charts display better in landscape orientation

  5. Limit table rows — Use maxLength to keep table charts readable

  6. Test with Run Now — Validate your configuration immediately before scheduling


Troubleshooting

Common Issues

IssueCauseSolution
Chart shows "No Data"Variable name mismatch between data selection and chart configurationVerify exact spelling and case of variableName
Wrong chart type displayedInference selected a different type than expectedExplicitly set chartType to override automatic inference
Chart type validation errorExplicit chartType is incompatible with the data structureUse a compatible chart type or adjust your Elasticsearch query
PDF document is excessively longTable chart has too many rowsAdd maxLength property to limit the number of displayed rows

See Also