diff --git a/README.md b/README.md index de6228d6..ecf477e6 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ Unless otherwise stated, the APIs with the same names as v1 APIs have a similar endpoints. The health check subset may not be a subset of the Envoy instance's EDS endpoints. * [Listener Discovery Service (LDS)](api/lds.proto). This new API supports dynamic discovery of the listener configuration (which ports to bind to, TLS details, filter chains, etc.). +* [Metric Service (MS)](api/metrics_service.proto). This new API allows Envoy to push (stream) metrics forever for servers to consume. * [Rate Limit Service (RLS)](api/rls.proto) * [Route Discovery Service (RDS)](api/rds.proto). * [Secret Discovery Service (SDS)](api/sds.proto). diff --git a/api/BUILD b/api/BUILD index c59fa0da..be7ec929 100644 --- a/api/BUILD +++ b/api/BUILD @@ -132,6 +132,17 @@ api_proto_library( ], ) +api_proto_library( + name = "metrics", + srcs = ["metrics_service.proto"], + has_services = 1, + deps = [ + ":base", + "@promotheus_metrics_model//:client_model_protos_lib", + ], + require_py = 0, +) + api_proto_library( name = "protocol", srcs = ["protocol.proto"], diff --git a/api/metrics_service.proto b/api/metrics_service.proto new file mode 100644 index 00000000..54e3fbc5 --- /dev/null +++ b/api/metrics_service.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package envoy.api.v2; + +import "api/base.proto"; + +import "google/api/annotations.proto"; +import "metrics.proto"; + +// Service for streaming metrics to server that consumes the metrics data. It uses Prometheus metric +// data model as a standard to represent metrics information. +service MetricsService { + // Envoy will connect and send StreamMetricsMessage messages forever. It does not expect any + // response to be sent as nothing would be done in the case of failure. + rpc StreamMetrics(stream StreamMetricsMessage) returns (StreamMetricsResponse) { + } +} + +message StreamMetricsResponse {} + +message StreamMetricsMessage { + message Identifier { + // The node sending the access log messages over the stream. + Node node = 1; + } + + // Identifier data effectively is a structured metadata. + // As a performance optimization this will only be sent in the first message on the stream. + Identifier identifier = 1; + + // A list of metric entries + repeated io.prometheus.client.MetricFamily envoy_metrics = 2; +} + +// Configuration structure. +message MetricsServiceConfig { + // The name of the upstream cluster that hosts the metrics service. The cluster must be + // configured in the cluster manager. + string cluster_name = 1; +} \ No newline at end of file diff --git a/bazel/api_build_system.bzl b/bazel/api_build_system.bzl index 211fcadc..d53fd96b 100644 --- a/bazel/api_build_system.bzl +++ b/bazel/api_build_system.bzl @@ -23,7 +23,7 @@ def api_py_proto_library(name, srcs = [], deps = [], has_services = 0): # TODO(htuch): has_services is currently ignored but will in future support # gRPC stub generation. -def api_proto_library(name, srcs = [], deps = [], has_services = 0): +def api_proto_library(name, srcs = [], deps = [], has_services = 0, require_py = 1): native.proto_library( name = name, srcs = srcs, @@ -43,7 +43,8 @@ def api_proto_library(name, srcs = [], deps = [], has_services = 0): deps = [name], visibility = ["//visibility:public"], ) - api_py_proto_library(name, srcs, deps, has_services) + if (require_py == 1): + api_py_proto_library(name, srcs, deps, has_services) def api_cc_test(name, srcs, proto_deps): native.cc_test( diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 8d979079..79c1a35f 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -1,4 +1,5 @@ GOOGLEAPIS_SHA = "5c6df0cd18c6a429eab739fb711c27f6e1393366" # May 14, 2017 +PROMETHEUS_SHA = "6f3806018612930941127f2a7c6c453ba2c527d2" # Nov 02, 2017 def api_dependencies(): native.new_http_archive( @@ -44,3 +45,31 @@ py_proto_library( ) """, ) + + native.new_http_archive( + name = "promotheus_metrics_model", + strip_prefix = "client_model-" + PROMETHEUS_SHA, + url = "https://github.com/prometheus/client_model/archive/" + PROMETHEUS_SHA + ".tar.gz", + build_file_content = """ + +filegroup( + name = "client_model_protos_src", + srcs = [ + "metrics.proto", + ], + visibility = ["//visibility:public"], + ) + +proto_library( + name = "client_model_protos_lib", + srcs = [":client_model_protos_src"], + visibility = ["//visibility:public"], +) + +cc_proto_library( + name = "client_model_protos", + deps = [":client_model_protos_lib"], + visibility = ["//visibility:public"], +) + """, + ) \ No newline at end of file diff --git a/test/build/BUILD b/test/build/BUILD index b320c395..eb6f13ef 100644 --- a/test/build/BUILD +++ b/test/build/BUILD @@ -12,6 +12,7 @@ api_cc_test( "//api:eds", "//api:hds", "//api:lds", + "//api:metrics", "//api:rds", "//api:rls", ], diff --git a/test/build/build_test.cc b/test/build/build_test.cc index dccfdd63..fa3cf846 100644 --- a/test/build/build_test.cc +++ b/test/build/build_test.cc @@ -16,6 +16,7 @@ int main(int argc, char *argv[]) { "envoy.api.v2.HealthDiscoveryService.StreamHealthCheck", "envoy.api.v2.ListenerDiscoveryService.FetchListeners", "envoy.api.v2.ListenerDiscoveryService.StreamListeners", + "envoy.api.v2.MetricsService.StreamMetrics", "envoy.api.v2.RouteDiscoveryService.FetchRoutes", "envoy.api.v2.RouteDiscoveryService.StreamRoutes", "envoy.api.v2.RateLimitService.ShouldRateLimit",