Considerations
Use Cases
Cardinality control- Raw SQL with embedded literals (e.g.
WHERE id = 1vsWHERE id = 2) creates high-cardinality query attributes and span names. Templatizing literals collapses those into a shared template such asWHERE id = ?.
- Lower cardinality on database spans improves aggregations, span metrics, and indexing in your observability backend, and can reduce storage volume.
- Replacing string and number literals removes many accidental secrets or PII that were inlined into SQL (passwords, emails, IDs) while keeping the query structure intact.
Configuration Options
The DbQueryTemplatization action is configured using theodigos.io/v1alpha1.Action CRD with the dbQueryTemplatization configuration section.
actionName
actionName
actionName
string : Allows you to attach a meaningful name to the action for convenience.- This field is optional
- Odigos does not use or assume any meaning from this field
notes
notes
notes
string : Allows you to attach notes regarding the action for convenience.- This field is optional
- Odigos does not use or assume any meaning from this field
disabled
disabled
disabled
boolean : Allows you to temporarily disable the action, but keep it saved for future use.- This field is optional, and defaults to
false
signals *
signals *
signals
string[] : An array with the signals that the action will operate on.- This field is required
- Supported values:
TRACES
dbQueryTemplatization *
dbQueryTemplatization *
dbQueryTemplatization
object : Configuration for the DbQueryTemplatization action.- This field is required for this action type
scopes
scopes
scopes
object : Limits which sources this templatization config applies to.- This field is optional
- If unset or empty, the config is applied to all sources.
- If multiple source scopes are set, they must all match simultaneously (AND logic).
sources
sources
sources
object[] : A list of workloads to apply this action to.- Each entry requires
name,namespace, andkind(Deployment,StatefulSet, etc.).
namespaces
namespaces
namespaces
string[] : Apply this action to all sources in the listed namespaces.languages
languages
languages
string[] : Apply this action only to containers instrumented with the listed programming languages.templatizeLiterals
templatizeLiterals
templatizeLiterals
boolean : When enabled, number and string literals in SQL queries are replaced with placeholders.- This field is optional, and defaults to
false - What is templatized:
- number literals (e.g.
1,3.14) - string literals (e.g.
'alice')
- number literals (e.g.
- What is not templatized:
- identifiers (table names, column names, etc.)
- positional parameters (e.g.
$1) - bind parameters (e.g.
:name) - boolean literals and
NULL - keywords, operators, punctuation, whitespace, comments, etc.
Basic Example
Given a span with:1
Create a YAML file with the following content:
db-query-templatization.yaml
2
Apply the action to the cluster:
Scoped Example
To limit templatization to specific workloads, addscopes. Omit scopes (or leave it empty) to apply the action to all sources.
db-query-templatization-scoped.yaml