• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;  // WILL BE GUARDRAILED TO 5 MINS UNLESS UID = SHELL OR ROOT
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  ONE_WEEK = 10;
48  CTS = 1000;
49}
50
51message FieldMatcher {
52  optional int32 field = 1;
53
54  optional Position position = 2;
55
56  repeated FieldMatcher child = 3;
57}
58
59message FieldValueMatcher {
60  optional int32 field = 1;
61
62  optional Position position = 2;
63
64  oneof value_matcher {
65    bool eq_bool = 3;
66    string eq_string = 4;
67    int64 eq_int = 5;
68
69    int64 lt_int = 6;
70    int64 gt_int = 7;
71    float lt_float = 8;
72    float gt_float = 9;
73
74    int64 lte_int = 10;
75    int64 gte_int = 11;
76
77    MessageMatcher matches_tuple = 12;
78
79    StringListMatcher eq_any_string = 13;
80    StringListMatcher neq_any_string = 14;
81  }
82}
83
84message MessageMatcher {
85  repeated FieldValueMatcher field_value_matcher = 1;
86}
87
88message StringListMatcher {
89    repeated string str_value = 1;
90}
91
92enum LogicalOperation {
93  LOGICAL_OPERATION_UNSPECIFIED = 0;
94  AND = 1;
95  OR = 2;
96  NOT = 3;
97  NAND = 4;
98  NOR = 5;
99}
100
101message SimpleAtomMatcher {
102  optional int32 atom_id = 1;
103
104  repeated FieldValueMatcher field_value_matcher = 2;
105}
106
107message AtomMatcher {
108  optional int64 id = 1;
109
110  message Combination {
111    optional LogicalOperation operation = 1;
112
113    repeated int64 matcher = 2;
114  }
115  oneof contents {
116    SimpleAtomMatcher simple_atom_matcher = 2;
117    Combination combination = 3;
118  }
119}
120
121message SimplePredicate {
122  optional int64 start = 1;
123
124  optional int64 stop = 2;
125
126  optional bool count_nesting = 3 [default = true];
127
128  optional int64 stop_all = 4;
129
130  enum InitialValue {
131    UNKNOWN = 0;
132    FALSE = 1;
133  }
134
135  // If unspecified, the default value will be UNKNOWN for conditions without dimensions, and
136  // FALSE for conditions with dimensions.
137  optional InitialValue initial_value = 5;
138
139  optional FieldMatcher dimensions = 6;
140}
141
142message Predicate {
143  optional int64 id = 1;
144
145  message Combination {
146    optional LogicalOperation operation = 1;
147
148    repeated int64 predicate = 2;
149  }
150
151  oneof contents {
152    SimplePredicate simple_predicate = 2;
153    Combination combination = 3;
154  }
155}
156
157message StateMap {
158  message StateGroup {
159    optional int64 group_id = 1;
160
161    repeated int32 value = 2;
162  }
163
164  repeated StateGroup group = 1;
165}
166
167message State {
168  optional int64 id = 1;
169
170  optional int32 atom_id = 2;
171
172  optional StateMap map = 3;
173}
174
175message MetricConditionLink {
176  optional int64 condition = 1;
177
178  optional FieldMatcher fields_in_what = 2;
179
180  optional FieldMatcher fields_in_condition = 3;
181}
182
183message MetricStateLink {
184  optional int32 state_atom_id = 1;
185
186  optional FieldMatcher fields_in_what = 2;
187
188  optional FieldMatcher fields_in_state = 3;
189}
190
191message FieldFilter {
192  optional bool include_all = 1 [default = false];
193  optional FieldMatcher fields = 2;
194}
195
196message UploadThreshold {
197    oneof value_comparison {
198        int64 lt_int = 1;
199        int64 gt_int = 2;
200        float lt_float = 3;
201        float gt_float = 4;
202        int64 lte_int = 5;
203        int64 gte_int = 6;
204    }
205}
206
207message EventMetric {
208  optional int64 id = 1;
209
210  optional int64 what = 2;
211
212  optional int64 condition = 3;
213
214  repeated MetricConditionLink links = 4;
215
216  reserved 100;
217  reserved 101;
218}
219
220message CountMetric {
221  optional int64 id = 1;
222
223  optional int64 what = 2;
224
225  optional int64 condition = 3;
226
227  optional FieldMatcher dimensions_in_what = 4;
228
229  repeated int64 slice_by_state = 8;
230
231  optional TimeUnit bucket = 5;
232
233  repeated MetricConditionLink links = 6;
234
235  repeated MetricStateLink state_link = 9;
236
237  optional UploadThreshold threshold = 10;
238
239  optional bool split_bucket_for_app_upgrade = 11;
240
241  optional FieldMatcher dimensions_in_condition = 7 [deprecated = true];
242
243  reserved 100;
244  reserved 101;
245}
246
247message DurationMetric {
248  optional int64 id = 1;
249
250  optional int64 what = 2;
251
252  optional int64 condition = 3;
253
254  repeated int64 slice_by_state = 9;
255
256  repeated MetricConditionLink links = 4;
257
258  repeated MetricStateLink state_link = 10;
259
260  enum AggregationType {
261    SUM = 1;
262
263    MAX_SPARSE = 2;
264  }
265  optional AggregationType aggregation_type = 5 [default = SUM];
266
267  optional FieldMatcher dimensions_in_what = 6;
268
269  optional TimeUnit bucket = 7;
270
271  optional UploadThreshold threshold = 11;
272
273  optional bool split_bucket_for_app_upgrade = 12;
274
275  optional FieldMatcher dimensions_in_condition = 8 [deprecated = true];
276
277  reserved 100;
278  reserved 101;
279}
280
281message GaugeMetric {
282  optional int64 id = 1;
283
284  optional int64 what = 2;
285
286  optional int64 trigger_event = 12;
287
288  optional FieldFilter gauge_fields_filter = 3;
289
290  optional int64 condition = 4;
291
292  optional FieldMatcher dimensions_in_what = 5;
293
294  optional FieldMatcher dimensions_in_condition = 8 [deprecated = true];
295
296  optional TimeUnit bucket = 6;
297
298  repeated MetricConditionLink links = 7;
299
300  enum SamplingType {
301    RANDOM_ONE_SAMPLE = 1;
302    ALL_CONDITION_CHANGES = 2 [deprecated = true];
303    CONDITION_CHANGE_TO_TRUE = 3;
304    FIRST_N_SAMPLES = 4;
305  }
306  optional SamplingType sampling_type = 9 [default = RANDOM_ONE_SAMPLE] ;
307
308  optional int64 min_bucket_size_nanos = 10;
309
310  optional int64 max_num_gauge_atoms_per_bucket = 11 [default = 10];
311
312  optional int32 max_pull_delay_sec = 13 [default = 30];
313
314  optional bool split_bucket_for_app_upgrade = 14;
315
316  reserved 100;
317  reserved 101;
318}
319
320message ValueMetric {
321  optional int64 id = 1;
322
323  optional int64 what = 2;
324
325  optional FieldMatcher value_field = 3;
326
327  optional int64 condition = 4;
328
329  optional FieldMatcher dimensions_in_what = 5;
330
331  repeated int64 slice_by_state = 18;
332
333  optional TimeUnit bucket = 6;
334
335  repeated MetricConditionLink links = 7;
336
337  repeated MetricStateLink state_link = 19;
338
339  optional UploadThreshold threshold = 20;
340
341  optional int64 condition_correction_threshold_nanos = 21;
342
343  enum AggregationType {
344    SUM = 1;
345    MIN = 2;
346    MAX = 3;
347    AVG = 4;
348  }
349  optional AggregationType aggregation_type = 8 [default = SUM];
350
351  optional int64 min_bucket_size_nanos = 10;
352
353  optional bool use_absolute_value_on_reset = 11 [default = false];
354
355  optional bool use_diff = 12;
356
357  optional bool use_zero_default_base = 15 [default = false];
358
359  enum ValueDirection {
360      UNKNOWN = 0;
361      INCREASING = 1;
362      DECREASING = 2;
363      ANY = 3;
364  }
365  optional ValueDirection value_direction = 13 [default = INCREASING];
366
367  optional bool skip_zero_diff_output = 14 [default = true];
368
369  optional int32 max_pull_delay_sec = 16 [default = 30];
370
371  optional bool split_bucket_for_app_upgrade = 17;
372
373  optional FieldMatcher dimensions_in_condition = 9 [deprecated = true];
374
375  reserved 100;
376  reserved 101;
377}
378
379message KllMetric {
380    optional int64 id = 1;
381
382    optional int64 what = 2;
383
384    optional FieldMatcher kll_field = 3;
385
386    optional int64 condition = 4;
387
388    optional FieldMatcher dimensions_in_what = 5;
389
390    optional TimeUnit bucket = 6;
391
392    repeated MetricConditionLink links = 7;
393
394    optional int64 min_bucket_size_nanos = 8;
395
396    optional bool split_bucket_for_app_upgrade = 9;
397
398    repeated int64 slice_by_state = 10;
399
400    repeated MetricStateLink state_link = 11;
401
402    reserved 100;
403    reserved 101;
404}
405
406message Alert {
407  optional int64 id = 1;
408
409  optional int64 metric_id = 2;
410
411  optional int32 num_buckets = 3;
412
413  optional int32 refractory_period_secs = 4;
414
415  optional double trigger_if_sum_gt = 5;
416}
417
418message Alarm {
419  optional int64 id = 1;
420
421  optional int64 offset_millis = 2;
422
423  optional int64 period_millis = 3;
424}
425
426message IncidentdDetails {
427  repeated int32 section = 1;
428
429  enum Destination {
430    AUTOMATIC = 0;
431    EXPLICIT = 1;
432  }
433  optional Destination dest = 2;
434
435  // Package name of the incident report receiver.
436  optional string receiver_pkg = 3;
437
438  // Class name of the incident report receiver.
439  optional string receiver_cls = 4;
440
441  optional string alert_description = 5;
442}
443
444message PerfettoDetails {
445  // The |trace_config| field is a proto-encoded message of type
446  // perfetto.protos.TraceConfig defined in
447  // //external/perfetto/protos/perfetto/config/. On device,
448  // statsd doesn't need to deserialize the message as it's just
449  // passed binary-encoded to the perfetto cmdline client.
450  optional bytes trace_config = 1;
451}
452
453message BroadcastSubscriberDetails {
454  optional int64 subscriber_id = 1;
455  repeated string cookie = 2;
456}
457
458message Subscription {
459  optional int64 id = 1;
460
461  enum RuleType {
462    RULE_TYPE_UNSPECIFIED = 0;
463    ALARM = 1;
464    ALERT = 2;
465  }
466  optional RuleType rule_type = 2;
467
468  optional int64 rule_id = 3;
469
470  oneof subscriber_information {
471    IncidentdDetails incidentd_details = 4;
472    PerfettoDetails perfetto_details = 5;
473    BroadcastSubscriberDetails broadcast_subscriber_details = 6;
474  }
475
476  optional float probability_of_informing = 7 [default = 1.1];
477
478  // This was used for perfprofd historically.
479  reserved 8;
480}
481
482enum ActivationType {
483  ACTIVATION_TYPE_UNKNOWN = 0;
484  ACTIVATE_IMMEDIATELY = 1;
485  ACTIVATE_ON_BOOT = 2;
486}
487
488message EventActivation {
489  optional int64 atom_matcher_id = 1;
490  optional int64 ttl_seconds = 2;
491  optional int64 deactivation_atom_matcher_id = 3;
492  optional ActivationType activation_type = 4;
493}
494
495message MetricActivation {
496  optional int64 metric_id = 1;
497
498  optional ActivationType activation_type = 3 [deprecated = true];
499
500  repeated EventActivation event_activation = 2;
501}
502
503message PullAtomPackages {
504    optional int32 atom_id = 1;
505
506    repeated string packages = 2;
507}
508
509message StatsdConfig {
510  optional int64 id = 1;
511
512  repeated EventMetric event_metric = 2;
513
514  repeated CountMetric count_metric = 3;
515
516  repeated ValueMetric value_metric = 4;
517
518  repeated GaugeMetric gauge_metric = 5;
519
520  repeated DurationMetric duration_metric = 6;
521
522  repeated KllMetric kll_metric = 25;
523
524  repeated AtomMatcher atom_matcher = 7;
525
526  repeated Predicate predicate = 8;
527
528  repeated Alert alert = 9;
529
530  repeated Alarm alarm = 10;
531
532  repeated Subscription subscription = 11;
533
534  repeated string allowed_log_source = 12;
535
536  repeated int64 no_report_metric = 13;
537
538  message Annotation {
539    optional int64 field_int64 = 1;
540    optional int32 field_int32 = 2;
541  }
542  repeated Annotation annotation = 14;
543
544  optional int64 ttl_in_seconds = 15;
545
546  optional bool hash_strings_in_metric_report = 16 [default = true];
547
548  repeated MetricActivation metric_activation = 17;
549
550  optional bool version_strings_in_metric_report = 18;
551
552  optional bool installer_in_metric_report = 19;
553
554  optional bool persist_locally = 20 [default = false];
555
556  repeated State state = 21;
557
558  repeated string default_pull_packages = 22;
559
560  repeated PullAtomPackages pull_atom_packages = 23;
561
562  repeated int32 whitelisted_atom_ids = 24;
563
564  optional uint32 package_certificate_hash_size_bytes = 26;
565
566  // Do not use.
567  reserved 1000, 1001;
568}
569