Metrics formatters
provide.foundation.integrations.openobserve.metrics_formatters
¶
Formatters for OpenObserve metrics output.
Provides various output formats for metrics data including tables, JSON, CSV, ASCII charts, and statistical summaries.
Classes¶
Functions¶
format_label_values
¶
Format label values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label_name
|
str
|
Name of the label |
required |
values
|
list[str]
|
List of values |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted string |
Source code in provide/foundation/integrations/openobserve/metrics_formatters.py
format_labels
¶
Format list of labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
labels
|
list[str]
|
List of label names |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted string |
Source code in provide/foundation/integrations/openobserve/metrics_formatters.py
format_metric_metadata
¶
Format metric metadata as a table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata
|
dict[str, list[dict[str, Any]]]
|
Dictionary mapping metric names to metadata list |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted string |
Source code in provide/foundation/integrations/openobserve/metrics_formatters.py
format_metric_output
¶
format_metric_output(
result: MetricQueryResult | list[str] | dict[str, Any],
format_type: str = "table",
pretty: bool = False,
) -> str
Format metrics output in specified format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
MetricQueryResult | list[str] | dict[str, Any]
|
Data to format (query result, list of metrics, or metadata) |
required |
format_type
|
str
|
Output format ("table", "json", "csv", "chart", "summary") |
'table'
|
pretty
|
bool
|
Whether to pretty-print (for JSON) |
False
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string |
Source code in provide/foundation/integrations/openobserve/metrics_formatters.py
format_metric_summary
¶
Format query result as statistical summary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
MetricQueryResult
|
Query result to summarize |
required |
Returns:
| Type | Description |
|---|---|
str
|
Summary string with statistics |
Source code in provide/foundation/integrations/openobserve/metrics_formatters.py
format_metrics_list
¶
Format list of metrics as a simple list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metrics
|
list[str]
|
List of metric names |
required |
show_count
|
bool
|
Whether to show count at the end |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string |
Source code in provide/foundation/integrations/openobserve/metrics_formatters.py
format_query_result_csv
¶
Format query result as CSV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
MetricQueryResult
|
Query result to format |
required |
Returns:
| Type | Description |
|---|---|
str
|
CSV string |
Source code in provide/foundation/integrations/openobserve/metrics_formatters.py
format_query_result_json
¶
Format query result as JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
MetricQueryResult
|
Query result to format |
required |
pretty
|
bool
|
Whether to pretty-print JSON |
False
|
Returns:
| Type | Description |
|---|---|
str
|
JSON string |
Source code in provide/foundation/integrations/openobserve/metrics_formatters.py
format_query_result_table
¶
Format query result as a table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
MetricQueryResult
|
Query result to format |
required |
Returns:
| Type | Description |
|---|---|
str
|
Formatted table string |
Source code in provide/foundation/integrations/openobserve/metrics_formatters.py
format_time_series_chart
¶
Format time series as ASCII chart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
MetricQueryResult
|
Query result with time series data |
required |
width
|
int
|
Chart width in characters |
60
|
height
|
int
|
Chart height in lines |
20
|
Returns:
| Type | Description |
|---|---|
str
|
ASCII chart string |