1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto2";
18
19package android.os.statsd;
20
21option java_package = "com.android.internal.os";
22option java_outer_classname = "StatsdConfigProto";
23
24enum Position {
25  POSITION_UNKNOWN = 0;
26
27  FIRST = 1;
28
29  LAST = 2;
30
31  ANY = 3;
32
33  ALL = 4;
34}
35
36enum TimeUnit {
37  TIME_UNIT_UNSPECIFIED = 0;
38  ONE_MINUTE = 1;
39  FIVE_MINUTES = 2;
40  TEN_MINUTES = 3;
41  THIRTY_MINUTES = 4;
42  ONE_HOUR = 5;
43  THREE_HOURS = 6;
44  SIX_HOURS = 7;
45  TWELVE_HOURS = 8;
46  ONE_DAY = 9;
47  CTS = 1000;
48}
49
50message FieldMatcher {
51  optional int32 field = 1;
52
53  optional Position position = 2;
54
55  repeated FieldMatcher child = 3;
56}
57
58message FieldValueMatcher {
59  optional int32 field = 1;
60
61  optional Position position = 2;
62
63  oneof value_matcher {
64    bool eq_bool = 3;
65    string eq_string = 4;
66    int64 eq_int = 5;
67
68    int64 lt_int = 6;
69    int64 gt_int = 7;
70    float lt_float = 8;
71    float gt_float = 9;
72
73    int64 lte_int = 10;
74    int64 gte_int = 11;
75
76    MessageMatcher matches_tuple = 12;
77
78    StringListMatcher eq_any_string = 13;
79    StringListMatcher neq_any_string = 14;
80  }
81}
82
83message MessageMatcher {
84  repeated FieldValueMatcher field_value_matcher = 1;
85}
86
87message StringListMatcher {
88    repeated string str_value = 1;
89}
90
91enum LogicalOperation {
92  LOGICAL_OPERATION_UNSPECIFIED = 0;
93  AND = 1;
94  OR = 2;
95  NOT = 3;
96  NAND = 4;
97  NOR = 5;
98}
99
100message SimpleAtomMatcher {
101  optional int32 atom_id = 1;
102
103  repeated FieldValueMatcher field_value_matcher = 2;
104}
105
106message AtomMatcher {
107  optional int64 id = 1;
108
109  message Combination {
110    optional LogicalOperation operation = 1;
111
112    repeated int64 matcher = 2;
113  }
114  oneof contents {
115    SimpleAtomMatcher simple_atom_matcher = 2;
116    Combination combination = 3;
117  }
118}
119
120message SimplePredicate {
121  optional int64 start = 1;
122
123  optional int64 stop = 2;
124
125  optional bool count_nesting = 3 [default = true];
126
127  optional int64 stop_all = 4;
128
129  enum InitialValue {
130    UNKNOWN = 0;
131    FALSE = 1;
132  }
133  optional InitialValue initial_value = 5 [default = FALSE];
134
135  optional FieldMatcher dimensions = 6;
136}
137
138message Predicate {
139  optional int64 id = 1;
140
141  message Combination {
142    optional LogicalOperation operation = 1;
143
144    repeated int64 predicate = 2;
145  }
146
147  oneof contents {
148    SimplePredicate simple_predicate = 2;
149    Combination combination = 3;
150  }
151}
152
153message MetricConditionLink {
154  optional int64 condition = 1;
155
156  optional FieldMatcher fields_in_what = 2;
157
158  optional FieldMatcher fields_in_condition = 3;
159}
160
161message FieldFilter {
162  optional bool include_all = 1 [default = false];
163  optional FieldMatcher fields = 2;
164}
165
166message EventMetric {
167  optional int64 id = 1;
168
169  optional int64 what = 2;
170
171  optional int64 condition = 3;
172
173  repeated MetricConditionLink links = 4;
174}
175
176message CountMetric {
177  optional int64 id = 1;
178
179  optional int64 what = 2;
180
181  optional int64 condition = 3;
182
183  optional FieldMatcher dimensions_in_what = 4;
184
185  optional FieldMatcher dimensions_in_condition = 7;
186
187  optional TimeUnit bucket = 5;
188
189  repeated MetricConditionLink links = 6;
190}
191
192message DurationMetric {
193  optional int64 id = 1;
194
195  optional int64 what = 2;
196
197  optional int64 condition = 3;
198
199  repeated MetricConditionLink links = 4;
200
201  enum AggregationType {
202    SUM = 1;
203
204    MAX_SPARSE = 2;
205  }
206  optional AggregationType aggregation_type = 5 [default = SUM];
207
208  optional FieldMatcher dimensions_in_what = 6;
209
210  optional FieldMatcher dimensions_in_condition = 8;
211
212  optional TimeUnit bucket = 7;
213}
214
215message GaugeMetric {
216  optional int64 id = 1;
217
218  optional int64 what = 2;
219
220  optional int64 trigger_event = 12;
221
222  optional FieldFilter gauge_fields_filter = 3;
223
224  optional int64 condition = 4;
225
226  optional FieldMatcher dimensions_in_what = 5;
227
228  optional FieldMatcher dimensions_in_condition = 8;
229
230  optional TimeUnit bucket = 6;
231
232  repeated MetricConditionLink links = 7;
233
234  enum SamplingType {
235    RANDOM_ONE_SAMPLE = 1;
236    ALL_CONDITION_CHANGES = 2 [deprecated = true];
237    CONDITION_CHANGE_TO_TRUE = 3;
238    FIRST_N_SAMPLES = 4;
239  }
240  optional SamplingType sampling_type = 9 [default = RANDOM_ONE_SAMPLE] ;
241
242  optional int64 min_bucket_size_nanos = 10;
243
244  optional int64 max_num_gauge_atoms_per_bucket = 11 [default = 10];
245
246  optional int32 max_pull_delay_sec = 13 [default = 10];
247
248  optional bool split_bucket_for_app_upgrade = 14 [default = true];
249}
250
251message ValueMetric {
252  optional int64 id = 1;
253
254  optional int64 what = 2;
255
256  optional FieldMatcher value_field = 3;
257
258  optional int64 condition = 4;
259
260  optional FieldMatcher dimensions_in_what = 5;
261
262  optional FieldMatcher dimensions_in_condition = 9;
263
264  optional TimeUnit bucket = 6;
265
266  repeated MetricConditionLink links = 7;
267
268  enum AggregationType {
269    SUM = 1;
270    MIN = 2;
271    MAX = 3;
272    AVG = 4;
273  }
274  optional AggregationType aggregation_type = 8 [default = SUM];
275
276  optional int64 min_bucket_size_nanos = 10;
277
278  optional bool use_absolute_value_on_reset = 11 [default = false];
279
280  optional bool use_diff = 12;
281
282  optional bool use_zero_default_base = 15 [default = false];
283
284  enum ValueDirection {
285      UNKNOWN = 0;
286      INCREASING = 1;
287      DECREASING = 2;
288      ANY = 3;
289  }
290  optional ValueDirection value_direction = 13 [default = INCREASING];
291
292  optional bool skip_zero_diff_output = 14 [default = true];
293
294  optional int32 max_pull_delay_sec = 16 [default = 10];
295
296  optional bool split_bucket_for_app_upgrade = 17 [default = true];
297}
298
299message Alert {
300  optional int64 id = 1;
301
302  optional int64 metric_id = 2;
303
304  optional int32 num_buckets = 3;
305
306  optional int32 refractory_period_secs = 4;
307
308  optional double trigger_if_sum_gt = 5;
309}
310
311message Alarm {
312  optional int64 id = 1;
313
314  optional int64 offset_millis = 2;
315
316  optional int64 period_millis = 3;
317}
318
319message IncidentdDetails {
320  repeated int32 section = 1;
321
322  enum Destination {
323    AUTOMATIC = 0;
324    EXPLICIT = 1;
325  }
326  optional Destination dest = 2;
327
328  // Package name of the incident report receiver.
329  optional string receiver_pkg = 3;
330
331  // Class name of the incident report receiver.
332  optional string receiver_cls = 4;
333
334  optional string alert_description = 5;
335}
336
337message PerfettoDetails {
338  // The |trace_config| field is a proto-encoded message of type
339  // perfetto.protos.TraceConfig defined in
340  // //external/perfetto/protos/perfetto/config/. On device,
341  // statsd doesn't need to deserialize the message as it's just
342  // passed binary-encoded to the perfetto cmdline client.
343  optional bytes trace_config = 1;
344}
345
346message BroadcastSubscriberDetails {
347  optional int64 subscriber_id = 1;
348  repeated string cookie = 2;
349}
350
351message Subscription {
352  optional int64 id = 1;
353
354  enum RuleType {
355    RULE_TYPE_UNSPECIFIED = 0;
356    ALARM = 1;
357    ALERT = 2;
358  }
359  optional RuleType rule_type = 2;
360
361  optional int64 rule_id = 3;
362
363  oneof subscriber_information {
364    IncidentdDetails incidentd_details = 4;
365    PerfettoDetails perfetto_details = 5;
366    BroadcastSubscriberDetails broadcast_subscriber_details = 6;
367  }
368
369  optional float probability_of_informing = 7 [default = 1.1];
370
371  // This was used for perfprofd historically.
372  reserved 8;
373}
374
375enum ActivationType {
376  ACTIVATION_TYPE_UNKNOWN = 0;
377  ACTIVATE_IMMEDIATELY = 1;
378  ACTIVATE_ON_BOOT = 2;
379}
380
381message EventActivation {
382  optional int64 atom_matcher_id = 1;
383  optional int64 ttl_seconds = 2;
384  optional int64 deactivation_atom_matcher_id = 3;
385  optional ActivationType activation_type = 4;
386}
387
388message MetricActivation {
389  optional int64 metric_id = 1;
390
391  optional ActivationType activation_type = 3 [deprecated = true];
392
393  repeated EventActivation event_activation = 2;
394}
395
396message StatsdConfig {
397  optional int64 id = 1;
398
399  repeated EventMetric event_metric = 2;
400
401  repeated CountMetric count_metric = 3;
402
403  repeated ValueMetric value_metric = 4;
404
405  repeated GaugeMetric gauge_metric = 5;
406
407  repeated DurationMetric duration_metric = 6;
408
409  repeated AtomMatcher atom_matcher = 7;
410
411  repeated Predicate predicate = 8;
412
413  repeated Alert alert = 9;
414
415  repeated Alarm alarm = 10;
416
417  repeated Subscription subscription = 11;
418
419  repeated string allowed_log_source = 12;
420
421  repeated int64 no_report_metric = 13;
422
423  message Annotation {
424    optional int64 field_int64 = 1;
425    optional int32 field_int32 = 2;
426  }
427  repeated Annotation annotation = 14;
428
429  optional int64 ttl_in_seconds = 15;
430
431  optional bool hash_strings_in_metric_report = 16 [default = true];
432
433  repeated MetricActivation metric_activation = 17;
434
435  optional bool version_strings_in_metric_report = 18;
436
437  optional bool installer_in_metric_report = 19;
438
439  optional bool persist_locally = 20 [default = false];
440
441  // Field number 1000 is reserved for later use.
442  reserved 1000;
443}
444