Metoro logo
Log inSign up

API reference

Logs API Reference


Get logs

Get logs allows you to query logs from the Metoro backend. You can filter logs based on time, service name, log attributes, resource attributes, and regexes. Results are limited to 100 logs per request, subsequent requests can be made by passing the prevEndTime field in the request.

POST https://us-east.metoro.io/api/v1/logs

The body of the request should be a GetLogsRequest object.

type GetLogsRequest struct {
    // 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"`

    // ExcludeFilters are filters that should be excluded from the logs
    // For example, if you want to get logs for all services except microservice_a you can pass in
    // {"service_name": ["microservice_a"]}
    ExcludeFilters map[string][]string `json:"excludeFilters"`

    // Previous page endTime in nanoseconds, used to get the next page of logs if there are more logs than the page size
    // If omitted, the first page of logs will be returned
    PrevEndTime *int64 `json:"prevEndTime"`

    // Regexes are used to filter logs based on a regex inclusively
    Regexes []string `json:"regexes"`

    // ExcludeRegexes are used to filter logs based on a regex exclusively
    ExcludeRegexes []string `json:"excludeRegexes"`

    // Ascending is used to sort the logs in ascending order. Default is descending
    Ascending      bool     `json:"ascending"`
}

The response will be a GetLogsResponse object.

type Log struct {
    // The time that the log line was emitted in milliseconds since the epoch
    Time int64 `json:"time"`
    // The severity of the log line
    Severity string `json:"severity"`
    // The log message
    Message string `json:"message"`
    // The attributes of the log line
    LogAttributes map[string]string `json:"logAttributes"`
    // The attributes of the resource that emitted the log line
    ResourceAttributes map[string]string `json:"resourceAttributes"`
    // Service name
    ServiceName string `json:"serviceName"`
}
	
type GetLogsResponse struct {
    // The logs that match the filters
    Logs []Log `json:"logs"`
}
Previous
Services
Next
Traces