// Copyright 2013 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package io.prometheus;

// A label/value pair suitable for attaching to timeseries.
message LabelPair {
	// The name of the label. Must adhere to the regex "[a-zA-Z_][a-zA-Z0-9_]*".
	optional string name = 1;
	// The value of the label. May contain any characters.
	optional string value = 2;
}

// A set of label/value pairs.
message LabelPairs {
	repeated LabelPair label = 1;
}

// The global Prometheus configuration section.
message GlobalConfig {
	// How frequently to scrape targets by default. Must be a valid Prometheus
	// duration string in the form "[0-9]+[smhdwy]".
	optional string scrape_interval = 1 [default = "1m"];
	// How frequently to evaluate rules by default. Must be a valid Prometheus
	// duration string in the form "[0-9]+[smhdwy]".
	optional string evaluation_interval = 2 [default = "1m"];
	// The labels to add to any timeseries that this Prometheus instance scrapes.
	optional LabelPairs labels = 3;
	// The list of file names of rule files to load.
	repeated string rule_file = 4;
}

// A labeled group of targets to scrape for a job.
message TargetGroup {
	// The list of endpoints to scrape via HTTP.
	repeated string target = 1;
	// The labels to add to any timeseries scraped for this target group.
	optional LabelPairs labels = 2;
}

// The configuration for a Prometheus job to scrape.
//
// The next field no. is 8.
message JobConfig {
	// The job name. Must adhere to the regex "[a-zA-Z_][a-zA-Z0-9_-]*".
	required string name = 1;
	// How frequently to scrape targets from this job. Overrides the global
	// default. Must be a valid Prometheus duration string in the form
	// "[0-9]+[smhdwy]".
	optional string scrape_interval = 2;
	// Per-target timeout when scraping this job. Must be a valid Prometheus
	// duration string in the form "[0-9]+[smhdwy]".
	optional string scrape_timeout = 7 [default = "10s"];
	// The DNS-SD service name pointing to SRV records containing endpoint
	// information for a job. When this field is provided, no target_group
	// elements may be set.
	optional string sd_name = 3;
	// Discovery refresh period when using DNS-SD to discover targets. Must be a
	// valid Prometheus duration string in the form "[0-9]+[smhdwy]".
	optional string sd_refresh_interval = 4 [default = "30s"];
	// List of labeled target groups for this job. Only legal when DNS-SD isn't
	// used for a job.
	repeated TargetGroup target_group = 5;
	// The HTTP resource path to fetch metrics from on targets.
	optional string metrics_path = 6 [default = "/metrics"];
}

// The top-level Prometheus configuration.
message PrometheusConfig {
	// Global Prometheus configuration options. If omitted, an empty global
	// configuration with default values (see GlobalConfig definition) will be
	// created.
	optional GlobalConfig global = 1;
	// The list of jobs to scrape.
	repeated JobConfig job = 2;
}
