Documentation
¶
Index ¶
- func ToWriteRequest(metrics []MetricData) *prompb.WriteRequest
- type CSVWriter
- type Field
- type Fields
- type KustoToMetricsTransformer
- type MetricData
- type MetricsCSVWriter
- type NativeLogsCSVWriter
- type RequestTransformer
- func (f *RequestTransformer) ShouldDropMetric(v *prompb.TimeSeries, name []byte) bool
- func (f *RequestTransformer) TransformTimeSeries(v *prompb.TimeSeries) *prompb.TimeSeries
- func (f *RequestTransformer) TransformWriteRequest(req *prompb.WriteRequest) *prompb.WriteRequest
- func (f *RequestTransformer) WalkLabels(v *prompb.TimeSeries, callback func(name []byte, value []byte))
- type TransformConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ToWriteRequest ¶ added in v0.2.0
func ToWriteRequest(metrics []MetricData) *prompb.WriteRequest
ToWriteRequest converts a slice of MetricData to a prompb.WriteRequest. This enables integration with PromToOtlpExporter for OTLP push-based delivery.
For high cardinality scenarios, callers should:
- Use WriteRequestPool to obtain the WriteRequest
- Call WriteRequest.Reset() and return to pool after use
The function creates one TimeSeries per MetricData entry. Labels are sorted by key to ensure consistent ordering (required by some backends).
Types ¶
type CSVWriter ¶
type CSVWriter struct {
// contains filtered or unexported fields
}
func NewCSVWriter ¶
NewCSVWriter returns a new CSVWriter that writes to the given buffer. The columns, if specified, are label keys that will be promoted to columns.
func (*CSVWriter) InitColumns ¶
InitColumns initializes the labels that will be promoted to columns in the CSV file. This can be done once on the *Writer and subsequent calls are no-ops.
type KustoToMetricsTransformer ¶ added in v0.2.0
type KustoToMetricsTransformer struct {
// contains filtered or unexported fields
}
KustoToMetricsTransformer transforms KQL query results to Prometheus metrics
func NewKustoToMetricsTransformer ¶ added in v0.2.0
func NewKustoToMetricsTransformer(config TransformConfig, meter metric.Meter) *KustoToMetricsTransformer
NewKustoToMetricsTransformer creates a new transformer instance
func (*KustoToMetricsTransformer) RegisterMetrics ¶ added in v0.2.0
func (t *KustoToMetricsTransformer) RegisterMetrics(ctx context.Context, metrics []MetricData) error
RegisterMetrics registers the metrics with the OpenTelemetry meter
func (*KustoToMetricsTransformer) Transform ¶ added in v0.2.0
func (t *KustoToMetricsTransformer) Transform(results []map[string]any) ([]MetricData, error)
Transform converts KQL query results to Prometheus metrics Supports both single-value and multi-value column modes
type MetricData ¶ added in v0.2.0
MetricData represents a single metric data point
type MetricsCSVWriter ¶
type MetricsCSVWriter struct {
// contains filtered or unexported fields
}
func NewMetricsCSVWriter ¶
func NewMetricsCSVWriter(w *bytes.Buffer, lifted Fields) *MetricsCSVWriter
NewMetricsCSVWriter returns a new CSVWriter that writes to the given buffer. The columns, if specified, are label keys that will be promoted to columns.
func NewMetricsCSVWriterWithSchema ¶
func NewMetricsCSVWriterWithSchema(w *bytes.Buffer, lifted Fields, mapping schema.SchemaMapping) *MetricsCSVWriter
NewMetricsCSVWriter returns a new CSVWriter that writes to the given buffer. The columns, if specified, are label keys that will be promoted to columns.
func (*MetricsCSVWriter) Bytes ¶
func (w *MetricsCSVWriter) Bytes() []byte
func (*MetricsCSVWriter) InitColumns ¶
func (w *MetricsCSVWriter) InitColumns(columns []string)
InitColumns initializes the labels that will be promoted to columns in the CSV file. This can be done once on the *Writer and subsequent calls are no-ops.
func (*MetricsCSVWriter) MarshalCSV ¶
func (w *MetricsCSVWriter) MarshalCSV(ts *prompb.TimeSeries) error
func (*MetricsCSVWriter) Reset ¶
func (w *MetricsCSVWriter) Reset()
func (*MetricsCSVWriter) SchemaHash ¶
func (w *MetricsCSVWriter) SchemaHash() uint64
type NativeLogsCSVWriter ¶
type NativeLogsCSVWriter struct {
// contains filtered or unexported fields
}
func NewCSVNativeLogsCSVWriter ¶
func NewCSVNativeLogsCSVWriter(w *bytes.Buffer, columns []string) *NativeLogsCSVWriter
NewCSVNativeLogsCSVWriter returns a new CSVWriter that writes to the given buffer. The columns, if specified, are label keys that will be promoted to columns.
func NewCSVNativeLogsCSVWriterWithSchema ¶
func NewCSVNativeLogsCSVWriterWithSchema(w *bytes.Buffer, columns []string, mapping schema.SchemaMapping) *NativeLogsCSVWriter
NewCSVNativeLogsCSVWriterWithSchema returns a new CSVWriter that writes to the given buffer. The columns, if specified, are label keys that will be promoted to columns.
func (*NativeLogsCSVWriter) Bytes ¶
func (w *NativeLogsCSVWriter) Bytes() []byte
func (*NativeLogsCSVWriter) InitColumns ¶
func (w *NativeLogsCSVWriter) InitColumns(columns []string)
InitColumns initializes the labels that will be promoted to columns in the CSV file. This can be done once on the *Writer and subsequent calls are no-ops.
func (*NativeLogsCSVWriter) MarshalNativeLog ¶
func (w *NativeLogsCSVWriter) MarshalNativeLog(log *types.Log) error
func (*NativeLogsCSVWriter) Reset ¶
func (w *NativeLogsCSVWriter) Reset()
func (*NativeLogsCSVWriter) SchemaHash ¶
func (w *NativeLogsCSVWriter) SchemaHash() uint64
type RequestTransformer ¶
type RequestTransformer struct {
// DefaultDropMetrics is a flag that indicates whether metrics should be dropped by default unless they match
// a keep rule.
DefaultDropMetrics bool
// KeepMetrics is a slice of regexes that keeps metrics when the metric name matches. A metric matching a
// Keep rule will not be dropped even if it matches a drop rule.
KeepMetrics []*regexp.Regexp
// KeepMetricsWithLabelValue is a map of regexes of label names to regexes of label values. When both match,
// the metric will be kept.
KeepMetricsWithLabelValue map[*regexp.Regexp]*regexp.Regexp
// DropLabels is a map of metric names regexes to label name regexes. When both match, the label will be dropped.
DropLabels map[*regexp.Regexp]*regexp.Regexp
// DropMetrics is a slice of regexes that drops metrics when the metric name matches. The metric name format
// should match the Prometheus naming style before the metric is translated to a Kusto table name.
DropMetrics []*regexp.Regexp
// AddLabels is a map of static label names to label values that will be added to all metrics.
// AddLabels takes precedence over any existing labels with the same name or any dynamic labels.
AddLabels map[string]string
// AllowedDatabase is a map of database names that are allowed to be written to.
AllowedDatabase map[string]struct{}
// DynamicLabeler is an optional labeler that adds dynamic labels from metadata sources.
DynamicLabeler metadata.MetricLabeler
// contains filtered or unexported fields
}
func (*RequestTransformer) ShouldDropMetric ¶
func (f *RequestTransformer) ShouldDropMetric(v *prompb.TimeSeries, name []byte) bool
func (*RequestTransformer) TransformTimeSeries ¶
func (f *RequestTransformer) TransformTimeSeries(v *prompb.TimeSeries) *prompb.TimeSeries
func (*RequestTransformer) TransformWriteRequest ¶
func (f *RequestTransformer) TransformWriteRequest(req *prompb.WriteRequest) *prompb.WriteRequest
func (*RequestTransformer) WalkLabels ¶ added in v0.2.0
func (f *RequestTransformer) WalkLabels(v *prompb.TimeSeries, callback func(name []byte, value []byte))
WalkLabels operates similarly to TransformTimeSeries, but instead of modifying the TimeSeries, it calls the callback with the key and value This is safe to call in parallel if the name and value bytes are not modified by the callback.
type TransformConfig ¶ added in v0.2.0
type TransformConfig struct {
// MetricNameColumn specifies which column contains the metric name
MetricNameColumn string `json:"metricNameColumn,omitempty"`
// MetricNamePrefix provides optional team/project namespacing for all metrics
MetricNamePrefix string `json:"metricNamePrefix,omitempty"`
// ValueColumns specifies columns to use as metric values (required)
ValueColumns []string `json:"valueColumns"`
// TimestampColumn specifies which column contains the timestamp
TimestampColumn string `json:"timestampColumn"`
// LabelColumns specifies columns to use as metric labels
LabelColumns []string `json:"labelColumns,omitempty"`
// DefaultMetricName provides a fallback if MetricNameColumn is not specified
DefaultMetricName string `json:"defaultMetricName,omitempty"`
}
TransformConfig defines how to convert KQL query results to metrics format