blob: c2a594b6415244ebc46053448d805c340b477840 [file] [log] [blame]
Alistair Veitchfb461ba2016-05-24 10:08:07 -07001// Copyright 2016, Google Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14// * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30syntax = "proto3";
31
32package google.census;
33
34// All the census protos.
35//
Alistair Veitche1ad41a2016-06-02 14:16:05 -070036// Nomenclature note: capitalized names below (like Resource) are protos.
Alistair Veitchfb461ba2016-05-24 10:08:07 -070037//
Alistair Veitche1ad41a2016-06-02 14:16:05 -070038// Census lets you define a Resource - something which can be measured, like the
Alistair Veitchfb461ba2016-05-24 10:08:07 -070039// latency of an RPC, the number of CPU cycles spent on an operation, or
40// anything else you care to measure. You can record individual instances of
Alistair Veitche1ad41a2016-06-02 14:16:05 -070041// measurements (a double value) for every Resource of interest. These
Alistair Veitchfb461ba2016-05-24 10:08:07 -070042// individual measurements are aggregated together into an Aggregation. There
43// are two Aggregation types available: Distribution (describes the
44// distribution of all measurements, possibly with a histogram) and
45// IntervalStats (the count and mean of measurements across specified time
46// periods). An Aggregation is described by an AggregationDescriptor.
47//
48// You can define how your stats are broken down by Tag values and which
49// Aggregations to use through a View. The corresponding combination of
Alistair Veitche1ad41a2016-06-02 14:16:05 -070050// Resource/View/Aggregation which is available to census clients is called a
51// Metric.
Alistair Veitchfb461ba2016-05-24 10:08:07 -070052
53
54// The following two types are copied from
55// google/protobuf/{duration,timestamp}.proto. Ideally, we would be able to
56// import them, but this causes compilation issues on C-based systems
57// (e.g. https://koti.kapsi.fi/jpa/nanopb/), which cannot process the C++
58// headers generated from the standard protobuf distribution. See the relevant
59// proto files for full documentation of these types.
60
61message Duration {
62 // Signed seconds of the span of time. Must be from -315,576,000,000
63 // to +315,576,000,000 inclusive.
64 int64 seconds = 1;
65
66 // Signed fractions of a second at nanosecond resolution of the span
67 // of time. Durations less than one second are represented with a 0
68 // `seconds` field and a positive or negative `nanos` field. For durations
69 // of one second or more, a non-zero value for the `nanos` field must be
70 // of the same sign as the `seconds` field. Must be from -999,999,999
71 // to +999,999,999 inclusive.
72 int32 nanos = 2;
73}
74
75message Timestamp {
76 // Represents seconds of UTC time since Unix epoch
77 // 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to
78 // 9999-12-31T23:59:59Z inclusive.
79 int64 seconds = 1;
80
81 // Non-negative fractions of a second at nanosecond resolution. Negative
82 // second values with fractions must still have non-negative nanos values
83 // that count forward in time. Must be from 0 to 999,999,999
84 // inclusive.
85 int32 nanos = 2;
86}
87
Alistair Veitche1ad41a2016-06-02 14:16:05 -070088// Describes a Resource.
89message Resource {
90 // name of resource, e.g. rpc_latency, cpu. Must be unique.
Alistair Veitchfb461ba2016-05-24 10:08:07 -070091 string name = 1;
92
Alistair Veitche1ad41a2016-06-02 14:16:05 -070093 // More detailed description of the resource, used in documentation.
Alistair Veitchfb461ba2016-05-24 10:08:07 -070094 string description = 2;
95
96 // Fundamental units of measurement supported by Census
97 // TODO(aveitch): expand this to include other S.I. units?
Alistair Veitche1ad41a2016-06-02 14:16:05 -070098 enum BasicUnit {
99 UNKNOWN = 0;
100 BITS = 1;
101 BYTES = 2;
102 SECS = 3;
103 CORES = 4;
104 MAX_UNITS = 5;
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700105 }
106
107 // MeasurementUnit lets you build compound units of the form
108 // 10^n * (A * B * ...) / (X * Y * ...),
109 // where the elements in the numerator and denominator are all BasicUnits. A
110 // MeasurementUnit must have at least one BasicUnit in its numerator.
111 //
112 // To specify multiplication in the numerator or denominator, simply specify
113 // multiple numerator or denominator fields. For example:
114 //
115 // - byte-seconds (i.e. bytes * seconds):
116 // numerator: BYTES
117 // numerator: SECS
118 //
119 // - events/sec^2 (i.e. rate of change of events/sec):
120 // numerator: COUNT
121 // denominator: SECS
122 // denominator: SECS
123 //
Alistair Veitch4eb67b42016-06-03 15:45:04 -0700124 // To specify multiples (in power of 10) of units, specify a non-zero prefix
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700125 // value, for example:
126 //
127 // - MB/s (i.e. megabytes / s):
128 // prefix: 6
129 // numerator: BYTES
130 // denominator: SECS
131 //
132 // - nanoseconds
133 // prefix: -9
134 // numerator: SECS
135 message MeasurementUnit {
136 int32 prefix = 1;
137 repeated BasicUnit numerator = 2;
138 repeated BasicUnit denominator = 3;
139 }
140
Alistair Veitche1ad41a2016-06-02 14:16:05 -0700141 // The units in which Resource values are measured.
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700142 MeasurementUnit unit = 3;
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700143}
144
Alistair Veitche1ad41a2016-06-02 14:16:05 -0700145// An Aggregation summarizes a series of individual Resource measurements, an
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700146// AggregationDescriptor describes an Aggregation.
147message AggregationDescriptor {
Alistair Veitch4eb67b42016-06-03 15:45:04 -0700148 enum AggregationType {
149 // Unspecified. Should not be used.
150 UNKNOWN = 0;
151 // A count of measurements made.
152 COUNT = 1;
153 // A Distribution.
154 DISTRIBUTION = 2;
155 // Counts over fixed time intervals.
156 INTERVAL = 3;
157 }
158 // The type of Aggregation.
159 AggregationType type = 1;
160
161 // At most one set of options. It is illegal to specifiy an option for
162 // COUNT Aggregations. interval_boundaries must be set for INTERVAL types.
163 // bucket_boundaries are optional for DISTRIBUTION types.
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700164 oneof options {
Alistair Veitch4eb67b42016-06-03 15:45:04 -0700165 // Defines histogram bucket boundaries for Distributions.
166 BucketBoundaries bucket_boundaries = 2;
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700167 // Defines the time windows to record for IntervalStats.
Alistair Veitch4eb67b42016-06-03 15:45:04 -0700168 IntervalBoundaries interval_boundaries = 3;
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700169 }
170
171 // A Distribution may optionally contain a histogram of the values in the
Alistair Veitch4eb67b42016-06-03 15:45:04 -0700172 // population. The bucket boundaries for that histogram are described by
173 // `bucket_boundaries`. This defines `size(bounds) + 1` (= N) buckets. The
174 // boundaries for bucket index i are:
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700175 //
176 // [-infinity, bounds[i]) for i == 0
177 // [bounds[i-1], bounds[i]) for 0 < i < N-2
178 // [bounds[i-1], +infinity) for i == N-1
179 //
180 // i.e. an underflow bucket (number 0), zero or more finite buckets (1
181 // through N - 2, and an overflow bucket (N - 1), with inclusive lower
182 // bounds and exclusive upper bounds.
183 //
184 // There must be at least one element in `bounds`. If `bounds` has only one
185 // element, there are no finite buckets, and that single element is the
186 // common boundary of the overflow and underflow buckets.
187 message BucketBoundaries {
188 // The values must be monotonically increasing.
189 repeated double bounds = 1;
190 }
191
192 // For Interval stats, describe the size of each window.
193 message IntervalBoundaries {
194 // For each time window, specify a duration in seconds.
195 repeated double window_size = 1;
196 }
197}
198
199// Distribution contains summary statistics for a population of values and,
200// optionally, a histogram representing the distribution of those values across
201// a specified set of histogram buckets, as defined in
202// Aggregation.bucket_options.
203//
Alistair Veitch4eb67b42016-06-03 15:45:04 -0700204// The summary statistics are the count, mean, minimum, and the maximum of the
205// set of population of values.
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700206//
207// Although it is not forbidden, it is generally a bad idea to include
208// non-finite values (infinities or NaNs) in the population of values, as this
209// will render the `mean` field meaningless.
210message Distribution {
211 // The number of values in the population. Must be non-negative.
212 int64 count = 1;
213
214 // The arithmetic mean of the values in the population. If `count` is zero
215 // then this field must be zero.
216 double mean = 2;
217
218 // Describes a range of population values.
219 message Range {
220 // The minimum of the population values.
221 double min = 1;
222 // The maximum of the population values.
223 double max = 2;
224 }
225
226 // The range of the population values. If `count` is zero, this field will not
227 // be defined.
228 Range range = 3;
229
230 // A Distribution may optionally contain a histogram of the values in the
231 // population. The histogram is given in `bucket_count` as counts of values
232 // that fall into one of a sequence of non-overlapping buckets, as described
233 // by `AggregationDescriptor.options.bucket_boundaries`.
234 // The sum of the values in `bucket_counts` must equal the value in `count`.
235 //
236 // Bucket counts are given in order under the numbering scheme described
237 // above (the underflow bucket has number 0; the finite buckets, if any,
238 // have numbers 1 through N-2; the overflow bucket has number N-1).
239 //
240 // The size of `bucket_count` must be no greater than N as defined in
241 // `bucket_boundaries`.
242 //
243 // Any suffix of trailing zero bucket_count fields may be omitted.
244 repeated int64 bucket_count = 4;
245}
246
247// Record summary stats over various time windows.
248message IntervalStats {
249 // Summary statistic over a single time window.
250 message Window {
Alistair Veitch4eb67b42016-06-03 15:45:04 -0700251 // The window duration. Must be positive.
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700252 Duration window_size = 1;
253 // The number of measurements in this window.
254 int64 count = 2;
255 // The arithmetic mean of all measurements in the window.
256 double mean = 3;
257 }
258
Alistair Veitche1ad41a2016-06-02 14:16:05 -0700259 // Full set of windows for this aggregation.
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700260 repeated Window window = 1;
261}
262
263// A Tag: key-value pair.
264message Tag {
265 string key = 1;
266 string value = 2;
267}
268
269// A View specifies an Aggregation and a set of tag keys. The Aggregation will
270// be broken down by the unique set of matching tag values for each measurement.
271message View {
Alistair Veitche1ad41a2016-06-02 14:16:05 -0700272 // Name of view. Must be unique.
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700273 string name = 1;
274
275 // More detailed description, for documentation purposes.
276 string description = 2;
277
Alistair Veitche1ad41a2016-06-02 14:16:05 -0700278 // Name of Resource to be broken down for this view.
279 string resource_name = 3;
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700280
281 // Aggregation type to associate with this View.
282 AggregationDescriptor aggregation = 4;
283
Alistair Veitche1ad41a2016-06-02 14:16:05 -0700284 // Tag keys to match with a given Resource measurement. If no keys are
285 // specified, then all stats are recorded. Keys must be unique.
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700286 repeated string tag_key = 5;
287}
288
Alistair Veitche1ad41a2016-06-02 14:16:05 -0700289// An Aggregation summarizes a series of individual Resource measurements.
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700290message Aggregation {
291 // Name of this aggregation.
292 string name = 1;
293
294 // More detailed description, for documentation purposes.
295 string description = 2;
296
297 // The data for this Aggregation.
298 oneof data {
Alistair Veitch4eb67b42016-06-03 15:45:04 -0700299 uint64 count = 3;
300 Distribution distribution = 4;
301 IntervalStats interval_stats = 5;
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700302 }
303
304 // Tags associated with this Aggregation.
Alistair Veitch4eb67b42016-06-03 15:45:04 -0700305 repeated Tag tag = 6;
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700306}
307
Alistair Veitche1ad41a2016-06-02 14:16:05 -0700308// A Metric represents all the Aggregations for a particular view.
309message Metric {
Alistair Veitch4eb67b42016-06-03 15:45:04 -0700310 // View associated with this Metric.
311 string view_name = 1;
312
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700313 // Aggregations - each will have a unique set of tag values for the tag_keys
314 // associated with the corresponding View.
Alistair Veitch4eb67b42016-06-03 15:45:04 -0700315 repeated Aggregation aggregation = 2;
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700316
Alistair Veitche1ad41a2016-06-02 14:16:05 -0700317 // Start and end timestamps over which the metric was accumulated. These
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700318 // values are not relevant/defined for IntervalStats aggregations, which are
319 // always accumulated over a fixed time period.
Alistair Veitch4eb67b42016-06-03 15:45:04 -0700320 Timestamp start = 3;
321 Timestamp end = 4;
Alistair Veitchfb461ba2016-05-24 10:08:07 -0700322}