• 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 StringReplacer {
60  // Regex for matching the string.
61  optional string regex = 1;
62
63  // String with which to replace the matched string.
64  optional string replacement = 2;
65}
66
67message FieldValueMatcher {
68  optional int32 field = 1;
69
70  optional Position position = 2;
71
72  oneof value_matcher {
73    bool eq_bool = 3;
74    string eq_string = 4;
75    int64 eq_int = 5;
76
77    int64 lt_int = 6;
78    int64 gt_int = 7;
79    float lt_float = 8;
80    float gt_float = 9;
81
82    int64 lte_int = 10;
83    int64 gte_int = 11;
84
85    MessageMatcher matches_tuple = 12;
86
87    StringListMatcher eq_any_string = 13;
88    StringListMatcher neq_any_string = 14;
89    IntListMatcher eq_any_int = 15;
90    IntListMatcher neq_any_int = 16;
91
92    string eq_wildcard_string = 17;
93    StringListMatcher eq_any_wildcard_string = 18;
94    StringListMatcher neq_any_wildcard_string = 19;
95  }
96
97  // Can only be present if either:
98  // 1. value_matcher is not set.
99  // 2. value_matcher is set to one that is applicable to string fields.
100  optional StringReplacer replace_string = 20;
101}
102
103message MessageMatcher {
104  repeated FieldValueMatcher field_value_matcher = 1;
105}
106
107message StringListMatcher {
108    repeated string str_value = 1;
109}
110
111message IntListMatcher {
112    repeated int64 int_value = 1;
113}
114
115enum LogicalOperation {
116  LOGICAL_OPERATION_UNSPECIFIED = 0;
117  AND = 1;
118  OR = 2;
119  NOT = 3;
120  NAND = 4;
121  NOR = 5;
122}
123
124message SimpleAtomMatcher {
125  optional int32 atom_id = 1;
126
127  repeated FieldValueMatcher field_value_matcher = 2;
128}
129
130message AtomMatcher {
131  optional int64 id = 1;
132
133  message Combination {
134    optional LogicalOperation operation = 1;
135
136    repeated int64 matcher = 2;
137  }
138  oneof contents {
139    SimpleAtomMatcher simple_atom_matcher = 2;
140    Combination combination = 3;
141  }
142}
143
144message SimplePredicate {
145  optional int64 start = 1;
146
147  optional int64 stop = 2;
148
149  optional bool count_nesting = 3 [default = true];
150
151  optional int64 stop_all = 4;
152
153  enum InitialValue {
154    UNKNOWN = 0;
155    FALSE = 1;
156  }
157
158  // If unspecified, the default value will be UNKNOWN for conditions without dimensions, and
159  // FALSE for conditions with dimensions.
160  optional InitialValue initial_value = 5;
161
162  optional FieldMatcher dimensions = 6;
163}
164
165message Predicate {
166  optional int64 id = 1;
167
168  message Combination {
169    optional LogicalOperation operation = 1;
170
171    repeated int64 predicate = 2;
172  }
173
174  oneof contents {
175    SimplePredicate simple_predicate = 2;
176    Combination combination = 3;
177  }
178}
179
180message StateMap {
181  message StateGroup {
182    optional int64 group_id = 1;
183
184    repeated int32 value = 2;
185  }
186
187  repeated StateGroup group = 1;
188}
189
190message State {
191  optional int64 id = 1;
192
193  optional int32 atom_id = 2;
194
195  optional StateMap map = 3;
196}
197
198message MetricConditionLink {
199  optional int64 condition = 1;
200
201  optional FieldMatcher fields_in_what = 2;
202
203  optional FieldMatcher fields_in_condition = 3;
204}
205
206message MetricStateLink {
207  optional int32 state_atom_id = 1;
208
209  optional FieldMatcher fields_in_what = 2;
210
211  optional FieldMatcher fields_in_state = 3;
212}
213
214message FieldFilter {
215  optional bool include_all = 1 [default = false];
216
217  oneof field_matcher {
218      FieldMatcher fields = 2;
219      FieldMatcher omit_fields = 3;
220  }
221}
222
223message UploadThreshold {
224    oneof value_comparison {
225        int64 lt_int = 1;
226        int64 gt_int = 2;
227        float lt_float = 3;
228        float gt_float = 4;
229        int64 lte_int = 5;
230        int64 gte_int = 6;
231    }
232}
233
234message DimensionalSamplingInfo {
235    optional FieldMatcher sampled_what_field = 1;
236
237    optional int32 shard_count = 2;
238}
239
240message EventMetric {
241  optional int64 id = 1;
242
243  optional int64 what = 2;
244
245  optional int64 condition = 3;
246
247  repeated int64 slice_by_state = 7;
248
249  repeated MetricConditionLink links = 4;
250
251  repeated MetricStateLink state_link = 8;
252
253  optional int32 sampling_percentage = 5 [default = 100];
254
255  optional FieldMatcher uid_fields = 6;
256
257  optional FieldFilter fields_filter = 9;
258
259  reserved 100;
260  reserved 101;
261}
262
263message CountMetric {
264  optional int64 id = 1;
265
266  optional int64 what = 2;
267
268  optional int64 condition = 3;
269
270  optional FieldMatcher dimensions_in_what = 4;
271
272  repeated int64 slice_by_state = 8;
273
274  optional TimeUnit bucket = 5;
275
276  repeated MetricConditionLink links = 6;
277
278  repeated MetricStateLink state_link = 9;
279
280  optional UploadThreshold threshold = 10;
281
282  optional bool split_bucket_for_app_upgrade = 11;
283
284  optional FieldMatcher dimensions_in_condition = 7 [deprecated = true];
285
286  optional DimensionalSamplingInfo dimensional_sampling_info = 12;
287
288  optional int32 max_dimensions_per_bucket = 13;
289
290  optional FieldMatcher uid_fields = 14;
291
292  reserved 100;
293  reserved 101;
294}
295
296message DurationMetric {
297  optional int64 id = 1;
298
299  optional int64 what = 2;
300
301  optional int64 condition = 3;
302
303  repeated int64 slice_by_state = 9;
304
305  repeated MetricConditionLink links = 4;
306
307  repeated MetricStateLink state_link = 10;
308
309  enum AggregationType {
310    SUM = 1;
311
312    MAX_SPARSE = 2;
313  }
314  optional AggregationType aggregation_type = 5 [default = SUM];
315
316  optional FieldMatcher dimensions_in_what = 6;
317
318  optional TimeUnit bucket = 7;
319
320  optional UploadThreshold threshold = 11;
321
322  optional bool split_bucket_for_app_upgrade = 12;
323
324  optional FieldMatcher dimensions_in_condition = 8 [deprecated = true];
325
326  optional DimensionalSamplingInfo dimensional_sampling_info = 13;
327
328  optional int32 max_dimensions_per_bucket = 14;
329
330  optional FieldMatcher uid_fields = 15;
331
332  reserved 100;
333  reserved 101;
334}
335
336message GaugeMetric {
337  optional int64 id = 1;
338
339  optional int64 what = 2;
340
341  optional int64 trigger_event = 12;
342
343  optional FieldFilter gauge_fields_filter = 3;
344
345  optional int64 condition = 4;
346
347  repeated int64 slice_by_state = 20;
348
349  optional FieldMatcher dimensions_in_what = 5;
350
351  optional FieldMatcher dimensions_in_condition = 8 [deprecated = true];
352
353  optional TimeUnit bucket = 6;
354
355  repeated MetricConditionLink links = 7;
356
357  repeated MetricStateLink state_link = 21;
358
359  enum SamplingType {
360    RANDOM_ONE_SAMPLE = 1;
361    ALL_CONDITION_CHANGES = 2 [deprecated = true];
362    CONDITION_CHANGE_TO_TRUE = 3;
363    FIRST_N_SAMPLES = 4;
364  }
365  optional SamplingType sampling_type = 9 [default = RANDOM_ONE_SAMPLE] ;
366
367  optional int64 min_bucket_size_nanos = 10;
368
369  optional int64 max_num_gauge_atoms_per_bucket = 11 [default = 10];
370
371  optional int32 max_pull_delay_sec = 13 [default = 30];
372
373  optional bool split_bucket_for_app_upgrade = 14;
374
375  optional DimensionalSamplingInfo dimensional_sampling_info = 15;
376
377  optional int32 max_dimensions_per_bucket = 16;
378
379  optional int32 sampling_percentage = 17 [default = 100];
380
381  optional int32 pull_probability = 18 [default = 100];
382
383  optional FieldMatcher uid_fields = 19;
384
385  reserved 100;
386  reserved 101;
387}
388
389// Empty proto message to indicate that histogram bins are populated in the client process.
390// No additional configuration parameters are needed in this message.
391message ClientAggregatedBins {
392}
393
394message HistogramBinConfig {
395  message ExplicitBins {
396    repeated float bin = 1;
397  }
398
399  message GeneratedBins {
400    enum Strategy {
401      UNKNOWN = 0;
402      LINEAR = 1;
403      EXPONENTIAL = 2;
404    }
405
406    optional float min = 1;
407    optional float max = 2;
408    optional int32 count = 3;
409    optional Strategy strategy = 4;
410  }
411
412  optional int64 id = 1;
413  oneof binning_strategy {
414    GeneratedBins generated_bins = 2;
415    ExplicitBins explicit_bins = 3;
416    ClientAggregatedBins client_aggregated_bins = 4;
417  }
418}
419
420message ValueMetric {
421  optional int64 id = 1;
422
423  optional int64 what = 2;
424
425  optional FieldMatcher value_field = 3;
426
427  optional int64 condition = 4;
428
429  optional FieldMatcher dimensions_in_what = 5;
430
431  repeated int64 slice_by_state = 18;
432
433  optional TimeUnit bucket = 6;
434
435  repeated MetricConditionLink links = 7;
436
437  repeated MetricStateLink state_link = 19;
438
439  optional UploadThreshold threshold = 20;
440
441  optional int64 condition_correction_threshold_nanos = 21;
442
443  enum AggregationType {
444    SUM = 1;
445    MIN = 2;
446    MAX = 3;
447    AVG = 4;
448    HISTOGRAM = 5;
449  }
450  optional AggregationType aggregation_type = 8 [default = SUM];
451
452  repeated AggregationType aggregation_types = 25;
453
454  // The number of entries should match the number of times HISTOGRAM appears in aggregation_types.
455  // Each i'th HistogramBinConfig corresponds to the i'th HISTOGRAM entry in aggregation_types so
456  // ordering matters.
457  repeated HistogramBinConfig histogram_bin_configs = 26;
458
459  optional bool include_sample_size = 22;
460
461  optional int64 min_bucket_size_nanos = 10;
462
463  optional bool use_absolute_value_on_reset = 11 [default = false];
464
465  optional bool use_diff = 12;
466
467  optional bool use_zero_default_base = 15 [default = false];
468
469  enum ValueDirection {
470      UNKNOWN = 0;
471      INCREASING = 1;
472      DECREASING = 2;
473      ANY = 3;
474  }
475  optional ValueDirection value_direction = 13 [default = INCREASING];
476
477  optional bool skip_zero_diff_output = 14 [default = true];
478
479  optional int32 max_pull_delay_sec = 16 [default = 30];
480
481  optional bool split_bucket_for_app_upgrade = 17;
482
483  optional FieldMatcher dimensions_in_condition = 9 [deprecated = true];
484
485  optional DimensionalSamplingInfo dimensional_sampling_info = 23;
486
487  optional int32 max_dimensions_per_bucket = 24;
488
489  optional FieldMatcher uid_fields = 27;
490
491  reserved 100;
492  reserved 101;
493}
494
495message KllMetric {
496  optional int64 id = 1;
497
498  optional int64 what = 2;
499
500  optional FieldMatcher kll_field = 3;
501
502  optional int64 condition = 4;
503
504  optional FieldMatcher dimensions_in_what = 5;
505
506  optional TimeUnit bucket = 6;
507
508  repeated MetricConditionLink links = 7;
509
510  optional int64 min_bucket_size_nanos = 8;
511
512  optional bool split_bucket_for_app_upgrade = 9;
513
514  repeated int64 slice_by_state = 10;
515
516  repeated MetricStateLink state_link = 11;
517
518  optional DimensionalSamplingInfo dimensional_sampling_info = 12;
519
520  optional int32 max_dimensions_per_bucket = 13;
521
522  optional FieldMatcher uid_fields = 14;
523
524  reserved 100;
525  reserved 101;
526}
527
528message Alert {
529  optional int64 id = 1;
530
531  optional int64 metric_id = 2;
532
533  optional int32 num_buckets = 3;
534
535  optional int32 refractory_period_secs = 4;
536
537  optional double trigger_if_sum_gt = 5;
538
539  optional float probability_of_informing = 6 [default = 1.1];
540}
541
542message Alarm {
543  optional int64 id = 1;
544
545  optional int64 offset_millis = 2;
546
547  optional int64 period_millis = 3;
548
549  optional float probability_of_informing = 4 [default = 1.1];
550}
551
552message IncidentdDetails {
553  repeated int32 section = 1;
554
555  enum Destination {
556    AUTOMATIC = 0;
557    EXPLICIT = 1;
558  }
559  optional Destination dest = 2;
560
561  // Package name of the incident report receiver.
562  optional string receiver_pkg = 3;
563
564  // Class name of the incident report receiver.
565  optional string receiver_cls = 4;
566
567  optional string alert_description = 5;
568}
569
570message PerfettoDetails {
571  // The |trace_config| field is a proto-encoded message of type
572  // perfetto.protos.TraceConfig defined in
573  // //external/perfetto/protos/perfetto/config/. On device,
574  // statsd doesn't need to deserialize the message as it's just
575  // passed binary-encoded to the perfetto cmdline client.
576  optional bytes trace_config = 1;
577}
578
579message UprobestatsDetails {
580  // The |config| field is a proto-encoded message of type
581  // uprobestats.protos.UprobestatsConfig defined in
582  // //packages/modules/UprobeStats/src/config.proto. On device,
583  // statsd doesn't need to deserialize the message as it's just
584  // passed binary-encoded to the Uprobestats API.
585  optional bytes config = 1;
586}
587
588message BroadcastSubscriberDetails {
589  optional int64 subscriber_id = 1;
590  repeated string cookie = 2;
591}
592
593message Subscription {
594  optional int64 id = 1;
595
596  enum RuleType {
597    RULE_TYPE_UNSPECIFIED = 0;
598    ALARM = 1;
599    ALERT = 2;
600  }
601  optional RuleType rule_type = 2;
602
603  optional int64 rule_id = 3;
604
605  oneof subscriber_information {
606    IncidentdDetails incidentd_details = 4;
607    PerfettoDetails perfetto_details = 5;
608    BroadcastSubscriberDetails broadcast_subscriber_details = 6;
609    UprobestatsDetails uprobestats_details = 9;
610  }
611
612  optional float probability_of_informing = 7 [default = 1.1];
613
614  // This was used for perfprofd historically.
615  reserved 8;
616}
617
618enum ActivationType {
619  ACTIVATION_TYPE_UNKNOWN = 0;
620  ACTIVATE_IMMEDIATELY = 1;
621  ACTIVATE_ON_BOOT = 2;
622}
623
624message EventActivation {
625  optional int64 atom_matcher_id = 1;
626  optional int64 ttl_seconds = 2;
627  optional int64 deactivation_atom_matcher_id = 3;
628  optional ActivationType activation_type = 4;
629}
630
631message MetricActivation {
632  optional int64 metric_id = 1;
633
634  optional ActivationType activation_type = 3 [deprecated = true];
635
636  repeated EventActivation event_activation = 2;
637}
638
639message PullAtomPackages {
640    optional int32 atom_id = 1;
641
642    repeated string packages = 2;
643}
644
645message StatsdConfig {
646  optional int64 id = 1;
647
648  repeated EventMetric event_metric = 2;
649
650  repeated CountMetric count_metric = 3;
651
652  repeated ValueMetric value_metric = 4;
653
654  repeated GaugeMetric gauge_metric = 5;
655
656  repeated DurationMetric duration_metric = 6;
657
658  repeated KllMetric kll_metric = 25;
659
660  repeated AtomMatcher atom_matcher = 7;
661
662  repeated Predicate predicate = 8;
663
664  repeated Alert alert = 9;
665
666  repeated Alarm alarm = 10;
667
668  repeated Subscription subscription = 11;
669
670  repeated string allowed_log_source = 12;
671
672  repeated int64 no_report_metric = 13;
673
674  message Annotation {
675    optional int64 field_int64 = 1;
676    optional int32 field_int32 = 2;
677  }
678  repeated Annotation annotation = 14;
679
680  optional int64 ttl_in_seconds = 15;
681
682  optional bool hash_strings_in_metric_report = 16 [default = true];
683
684  repeated MetricActivation metric_activation = 17;
685
686  optional bool version_strings_in_metric_report = 18;
687
688  optional bool installer_in_metric_report = 19;
689
690  optional bool persist_locally = 20 [default = false];
691
692  repeated State state = 21;
693
694  repeated string default_pull_packages = 22;
695
696  repeated PullAtomPackages pull_atom_packages = 23;
697
698  repeated int32 whitelisted_atom_ids = 24;
699
700  optional uint32 package_certificate_hash_size_bytes = 26;
701
702  optional string restricted_metrics_delegate_package_name = 27;
703
704  optional int32 max_metrics_memory_kb = 28;
705
706  optional int32 soft_metrics_memory_kb = 29;
707
708  message StatsdConfigOptions {
709    optional bool use_v2_soft_memory_limit = 1;
710    optional bool omit_system_uids_in_uidmap = 2;
711    optional bool omit_unused_uids_in_uidmap = 3;
712    repeated string uidmap_package_allowlist = 4;
713  }
714
715  optional StatsdConfigOptions statsd_config_options = 30;
716
717  // Do not use.
718  reserved 1000, 1001;
719}
720