stats.proto 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. syntax = "proto3";
  2. package envoy.config.metrics.v2;
  3. import "envoy/api/v2/core/address.proto";
  4. import "envoy/type/matcher/string.proto";
  5. import "google/protobuf/any.proto";
  6. import "google/protobuf/struct.proto";
  7. import "google/protobuf/wrappers.proto";
  8. import "udpa/annotations/status.proto";
  9. import "validate/validate.proto";
  10. option java_package = "io.envoyproxy.envoy.config.metrics.v2";
  11. option java_outer_classname = "StatsProto";
  12. option java_multiple_files = true;
  13. option go_package = "github.com/envoyproxy/go-control-plane/envoy/config/metrics/v2;metricsv2";
  14. option (udpa.annotations.file_status).package_version_status = FROZEN;
  15. // [#protodoc-title: Stats]
  16. // Statistics :ref:`architecture overview <arch_overview_statistics>`.
  17. // Configuration for pluggable stats sinks.
  18. message StatsSink {
  19. // The name of the stats sink to instantiate. The name must match a supported
  20. // stats sink. The built-in stats sinks are:
  21. //
  22. // * :ref:`envoy.stat_sinks.statsd <envoy_api_msg_config.metrics.v2.StatsdSink>`
  23. // * :ref:`envoy.stat_sinks.dog_statsd <envoy_api_msg_config.metrics.v2.DogStatsdSink>`
  24. // * :ref:`envoy.stat_sinks.metrics_service <envoy_api_msg_config.metrics.v2.MetricsServiceConfig>`
  25. // * :ref:`envoy.stat_sinks.hystrix <envoy_api_msg_config.metrics.v2.HystrixSink>`
  26. //
  27. // Sinks optionally support tagged/multiple dimensional metrics.
  28. string name = 1;
  29. // Stats sink specific configuration which depends on the sink being instantiated. See
  30. // :ref:`StatsdSink <envoy_api_msg_config.metrics.v2.StatsdSink>` for an example.
  31. oneof config_type {
  32. google.protobuf.Struct config = 2 [deprecated = true];
  33. google.protobuf.Any typed_config = 3;
  34. }
  35. }
  36. // Statistics configuration such as tagging.
  37. message StatsConfig {
  38. // Each stat name is iteratively processed through these tag specifiers.
  39. // When a tag is matched, the first capture group is removed from the name so
  40. // later :ref:`TagSpecifiers <envoy_api_msg_config.metrics.v2.TagSpecifier>` cannot match that
  41. // same portion of the match.
  42. repeated TagSpecifier stats_tags = 1;
  43. // Use all default tag regexes specified in Envoy. These can be combined with
  44. // custom tags specified in :ref:`stats_tags
  45. // <envoy_api_field_config.metrics.v2.StatsConfig.stats_tags>`. They will be processed before
  46. // the custom tags.
  47. //
  48. // .. note::
  49. //
  50. // If any default tags are specified twice, the config will be considered
  51. // invalid.
  52. //
  53. // See :repo:`well_known_names.h <source/common/config/well_known_names.h>` for a list of the
  54. // default tags in Envoy.
  55. //
  56. // If not provided, the value is assumed to be true.
  57. google.protobuf.BoolValue use_all_default_tags = 2;
  58. // Inclusion/exclusion matcher for stat name creation. If not provided, all stats are instantiated
  59. // as normal. Preventing the instantiation of certain families of stats can improve memory
  60. // performance for Envoys running especially large configs.
  61. //
  62. // .. warning::
  63. // Excluding stats may affect Envoy's behavior in undocumented ways. See
  64. // `issue #8771 <https://github.com/envoyproxy/envoy/issues/8771>`_ for more information.
  65. // If any unexpected behavior changes are observed, please open a new issue immediately.
  66. StatsMatcher stats_matcher = 3;
  67. }
  68. // Configuration for disabling stat instantiation.
  69. message StatsMatcher {
  70. // The instantiation of stats is unrestricted by default. If the goal is to configure Envoy to
  71. // instantiate all stats, there is no need to construct a StatsMatcher.
  72. //
  73. // However, StatsMatcher can be used to limit the creation of families of stats in order to
  74. // conserve memory. Stats can either be disabled entirely, or they can be
  75. // limited by either an exclusion or an inclusion list of :ref:`StringMatcher
  76. // <envoy_api_msg_type.matcher.StringMatcher>` protos:
  77. //
  78. // * If `reject_all` is set to `true`, no stats will be instantiated. If `reject_all` is set to
  79. // `false`, all stats will be instantiated.
  80. //
  81. // * If an exclusion list is supplied, any stat name matching *any* of the StringMatchers in the
  82. // list will not instantiate.
  83. //
  84. // * If an inclusion list is supplied, no stats will instantiate, except those matching *any* of
  85. // the StringMatchers in the list.
  86. //
  87. //
  88. // A StringMatcher can be used to match against an exact string, a suffix / prefix, or a regex.
  89. // **NB:** For performance reasons, it is highly recommended to use a prefix- or suffix-based
  90. // matcher rather than a regex-based matcher.
  91. //
  92. // Example 1. Excluding all stats.
  93. //
  94. // .. code-block:: json
  95. //
  96. // {
  97. // "statsMatcher": {
  98. // "rejectAll": "true"
  99. // }
  100. // }
  101. //
  102. // Example 2. Excluding all cluster-specific stats, but not cluster-manager stats:
  103. //
  104. // .. code-block:: json
  105. //
  106. // {
  107. // "statsMatcher": {
  108. // "exclusionList": {
  109. // "patterns": [
  110. // {
  111. // "prefix": "cluster."
  112. // }
  113. // ]
  114. // }
  115. // }
  116. // }
  117. //
  118. // Example 3. Including only manager-related stats:
  119. //
  120. // .. code-block:: json
  121. //
  122. // {
  123. // "statsMatcher": {
  124. // "inclusionList": {
  125. // "patterns": [
  126. // {
  127. // "prefix": "cluster_manager."
  128. // },
  129. // {
  130. // "prefix": "listener_manager."
  131. // }
  132. // ]
  133. // }
  134. // }
  135. // }
  136. //
  137. oneof stats_matcher {
  138. option (validate.required) = true;
  139. // If `reject_all` is true, then all stats are disabled. If `reject_all` is false, then all
  140. // stats are enabled.
  141. bool reject_all = 1;
  142. // Exclusive match. All stats are enabled except for those matching one of the supplied
  143. // StringMatcher protos.
  144. type.matcher.ListStringMatcher exclusion_list = 2;
  145. // Inclusive match. No stats are enabled except for those matching one of the supplied
  146. // StringMatcher protos.
  147. type.matcher.ListStringMatcher inclusion_list = 3;
  148. }
  149. }
  150. // Designates a tag name and value pair. The value may be either a fixed value
  151. // or a regex providing the value via capture groups. The specified tag will be
  152. // unconditionally set if a fixed value, otherwise it will only be set if one
  153. // or more capture groups in the regex match.
  154. message TagSpecifier {
  155. // Attaches an identifier to the tag values to identify the tag being in the
  156. // sink. Envoy has a set of default names and regexes to extract dynamic
  157. // portions of existing stats, which can be found in :repo:`well_known_names.h
  158. // <source/common/config/well_known_names.h>` in the Envoy repository. If a :ref:`tag_name
  159. // <envoy_api_field_config.metrics.v2.TagSpecifier.tag_name>` is provided in the config and
  160. // neither :ref:`regex <envoy_api_field_config.metrics.v2.TagSpecifier.regex>` or
  161. // :ref:`fixed_value <envoy_api_field_config.metrics.v2.TagSpecifier.fixed_value>` were specified,
  162. // Envoy will attempt to find that name in its set of defaults and use the accompanying regex.
  163. //
  164. // .. note::
  165. //
  166. // It is invalid to specify the same tag name twice in a config.
  167. string tag_name = 1;
  168. oneof tag_value {
  169. // Designates a tag to strip from the tag extracted name and provide as a named
  170. // tag value for all statistics. This will only occur if any part of the name
  171. // matches the regex provided with one or more capture groups.
  172. //
  173. // The first capture group identifies the portion of the name to remove. The
  174. // second capture group (which will normally be nested inside the first) will
  175. // designate the value of the tag for the statistic. If no second capture
  176. // group is provided, the first will also be used to set the value of the tag.
  177. // All other capture groups will be ignored.
  178. //
  179. // Example 1. a stat name ``cluster.foo_cluster.upstream_rq_timeout`` and
  180. // one tag specifier:
  181. //
  182. // .. code-block:: json
  183. //
  184. // {
  185. // "tag_name": "envoy.cluster_name",
  186. // "regex": "^cluster\\.((.+?)\\.)"
  187. // }
  188. //
  189. // Note that the regex will remove ``foo_cluster.`` making the tag extracted
  190. // name ``cluster.upstream_rq_timeout`` and the tag value for
  191. // ``envoy.cluster_name`` will be ``foo_cluster`` (note: there will be no
  192. // ``.`` character because of the second capture group).
  193. //
  194. // Example 2. a stat name
  195. // ``http.connection_manager_1.user_agent.ios.downstream_cx_total`` and two
  196. // tag specifiers:
  197. //
  198. // .. code-block:: json
  199. //
  200. // [
  201. // {
  202. // "tag_name": "envoy.http_user_agent",
  203. // "regex": "^http(?=\\.).*?\\.user_agent\\.((.+?)\\.)\\w+?$"
  204. // },
  205. // {
  206. // "tag_name": "envoy.http_conn_manager_prefix",
  207. // "regex": "^http\\.((.*?)\\.)"
  208. // }
  209. // ]
  210. //
  211. // The two regexes of the specifiers will be processed in the definition order.
  212. //
  213. // The first regex will remove ``ios.``, leaving the tag extracted name
  214. // ``http.connection_manager_1.user_agent.downstream_cx_total``. The tag
  215. // ``envoy.http_user_agent`` will be added with tag value ``ios``.
  216. //
  217. // The second regex will remove ``connection_manager_1.`` from the tag
  218. // extracted name produced by the first regex
  219. // ``http.connection_manager_1.user_agent.downstream_cx_total``, leaving
  220. // ``http.user_agent.downstream_cx_total`` as the tag extracted name. The tag
  221. // ``envoy.http_conn_manager_prefix`` will be added with the tag value
  222. // ``connection_manager_1``.
  223. string regex = 2 [(validate.rules).string = {max_bytes: 1024}];
  224. // Specifies a fixed tag value for the ``tag_name``.
  225. string fixed_value = 3;
  226. }
  227. }
  228. // Stats configuration proto schema for built-in *envoy.stat_sinks.statsd* sink. This sink does not support
  229. // tagged metrics.
  230. // [#extension: envoy.stat_sinks.statsd]
  231. message StatsdSink {
  232. oneof statsd_specifier {
  233. option (validate.required) = true;
  234. // The UDP address of a running `statsd <https://github.com/etsy/statsd>`_
  235. // compliant listener. If specified, statistics will be flushed to this
  236. // address.
  237. api.v2.core.Address address = 1;
  238. // The name of a cluster that is running a TCP `statsd
  239. // <https://github.com/etsy/statsd>`_ compliant listener. If specified,
  240. // Envoy will connect to this cluster to flush statistics.
  241. string tcp_cluster_name = 2;
  242. }
  243. // Optional custom prefix for StatsdSink. If
  244. // specified, this will override the default prefix.
  245. // For example:
  246. //
  247. // .. code-block:: json
  248. //
  249. // {
  250. // "prefix" : "envoy-prod"
  251. // }
  252. //
  253. // will change emitted stats to
  254. //
  255. // .. code-block:: cpp
  256. //
  257. // envoy-prod.test_counter:1|c
  258. // envoy-prod.test_timer:5|ms
  259. //
  260. // Note that the default prefix, "envoy", will be used if a prefix is not
  261. // specified.
  262. //
  263. // Stats with default prefix:
  264. //
  265. // .. code-block:: cpp
  266. //
  267. // envoy.test_counter:1|c
  268. // envoy.test_timer:5|ms
  269. string prefix = 3;
  270. }
  271. // Stats configuration proto schema for built-in *envoy.stat_sinks.dog_statsd* sink.
  272. // The sink emits stats with `DogStatsD <https://docs.datadoghq.com/guides/dogstatsd/>`_
  273. // compatible tags. Tags are configurable via :ref:`StatsConfig
  274. // <envoy_api_msg_config.metrics.v2.StatsConfig>`.
  275. // [#extension: envoy.stat_sinks.dog_statsd]
  276. message DogStatsdSink {
  277. reserved 2;
  278. oneof dog_statsd_specifier {
  279. option (validate.required) = true;
  280. // The UDP address of a running DogStatsD compliant listener. If specified,
  281. // statistics will be flushed to this address.
  282. api.v2.core.Address address = 1;
  283. }
  284. // Optional custom metric name prefix. See :ref:`StatsdSink's prefix field
  285. // <envoy_api_field_config.metrics.v2.StatsdSink.prefix>` for more details.
  286. string prefix = 3;
  287. }
  288. // Stats configuration proto schema for built-in *envoy.stat_sinks.hystrix* sink.
  289. // The sink emits stats in `text/event-stream
  290. // <https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events>`_
  291. // formatted stream for use by `Hystrix dashboard
  292. // <https://github.com/Netflix-Skunkworks/hystrix-dashboard/wiki>`_.
  293. //
  294. // Note that only a single HystrixSink should be configured.
  295. //
  296. // Streaming is started through an admin endpoint :http:get:`/hystrix_event_stream`.
  297. // [#extension: envoy.stat_sinks.hystrix]
  298. message HystrixSink {
  299. // The number of buckets the rolling statistical window is divided into.
  300. //
  301. // Each time the sink is flushed, all relevant Envoy statistics are sampled and
  302. // added to the rolling window (removing the oldest samples in the window
  303. // in the process). The sink then outputs the aggregate statistics across the
  304. // current rolling window to the event stream(s).
  305. //
  306. // rolling_window(ms) = stats_flush_interval(ms) * num_of_buckets
  307. //
  308. // More detailed explanation can be found in `Hystrix wiki
  309. // <https://github.com/Netflix/Hystrix/wiki/Metrics-and-Monitoring#hystrixrollingnumber>`_.
  310. int64 num_buckets = 1;
  311. }