API reference
Metrics API Reference
Get metrics
Get logs allows you to query metrics from the Metoro backend. You can filter metrics based on time, service name and attributes. You can also group the returned metrics by attributes.
POST https://us-east.metoro.io/api/v1/metric
The body of the request should be a GetMetricRequest
object.
type GetMetricRequest struct {
// MetricName is the name of the metric to get
MetricName string `json:"metricName"`
// Start time of when to get the logs in seconds since epoch
StartTime int64 `json:"startTime"`
// End time of when to get the logs in seconds since epoch
EndTime int64 `json:"endTime"`
// The filters to apply to the logs, so for example, if you want to get logs for a specific service
// you can pass in a filter like {"service_name": ["microservice_a"]}
Filters map[string][]string `json:"filters"`
// Splits is a list of attributes to split the metrics by, for example, if you want to split the metrics by service
// you can pass in a list like ["service_name"]
Splits []string `json:"splits"`
// Aggregation is the operation to apply to the metrics, for example, if you want to sum the metrics you can pass in "sum"
Aggregation Aggregation `json:"aggregation"`
// IsRate is a flag to indicate if the metric is a rate metric
IsRate bool `json:"isRate"`
}
The response will be a GetMetricResponse
object.
type GetMetricResponse struct {
Metric Metric `json:"metric"`
}
type Metric struct {
// Name of the metric
Name string `json:"name"`
// TimeSeries is the time series of the metric
TimeSeries []TimeSeries `json:"timeSeries"`
// Type of the metric
Type string `json:"type"`
// The common attributes of the metric
Attributes map[string][]string `json:"attributes"`
// The unit of the metric
Unit string `json:"unit"`
}
type TimeSeries struct {
// The data points of the time series
Data []DataPoint `json:"data"`
// The attributes that are specific to this time series
Attributes map[string]string `json:"attributes"`
}
type DataPoint struct {
// The time of the data point in milliseconds since epoch
Time int64 `json:"time"`
// The value of the data point if any data was emitted
Value *float64 `json:"value"`
}