summaryrefslogtreecommitdiff
path: root/cmds/statsd/src/statsd_config.proto
blob: acdffd3d4712c7ac983b86d624d33e5508945c35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package android.os.statsd;

option java_package = "com.android.internal.os";
option java_outer_classname = "StatsdConfigProto";

enum Position {
  POSITION_UNKNOWN = 0;

  FIRST = 1;

  LAST = 2;

  ANY = 3;

  ALL = 4;
}

enum TimeUnit {
  TIME_UNIT_UNSPECIFIED = 0;
  ONE_MINUTE = 1;  // WILL BE GUARDRAILED TO 5 MINS UNLESS UID = SHELL OR ROOT
  FIVE_MINUTES = 2;
  TEN_MINUTES = 3;
  THIRTY_MINUTES = 4;
  ONE_HOUR = 5;
  THREE_HOURS = 6;
  SIX_HOURS = 7;
  TWELVE_HOURS = 8;
  ONE_DAY = 9;
  ONE_WEEK = 10;
  CTS = 1000;
}

message FieldMatcher {
  optional int32 field = 1;

  optional Position position = 2;

  repeated FieldMatcher child = 3;
}

message FieldValueMatcher {
  optional int32 field = 1;

  optional Position position = 2;

  oneof value_matcher {
    bool eq_bool = 3;
    string eq_string = 4;
    int64 eq_int = 5;

    int64 lt_int = 6;
    int64 gt_int = 7;
    float lt_float = 8;
    float gt_float = 9;

    int64 lte_int = 10;
    int64 gte_int = 11;

    MessageMatcher matches_tuple = 12;

    StringListMatcher eq_any_string = 13;
    StringListMatcher neq_any_string = 14;
  }
}

message MessageMatcher {
  repeated FieldValueMatcher field_value_matcher = 1;
}

message StringListMatcher {
    repeated string str_value = 1;
}

enum LogicalOperation {
  LOGICAL_OPERATION_UNSPECIFIED = 0;
  AND = 1;
  OR = 2;
  NOT = 3;
  NAND = 4;
  NOR = 5;
}

message SimpleAtomMatcher {
  optional int32 atom_id = 1;

  repeated FieldValueMatcher field_value_matcher = 2;
}

message AtomMatcher {
  optional int64 id = 1;

  message Combination {
    optional LogicalOperation operation = 1;

    repeated int64 matcher = 2;
  }
  oneof contents {
    SimpleAtomMatcher simple_atom_matcher = 2;
    Combination combination = 3;
  }
}

message SimplePredicate {
  optional int64 start = 1;

  optional int64 stop = 2;

  optional bool count_nesting = 3 [default = true];

  optional int64 stop_all = 4;

  enum InitialValue {
    UNKNOWN = 0;
    FALSE = 1;
  }
  optional InitialValue initial_value = 5 [default = UNKNOWN];

  optional FieldMatcher dimensions = 6;
}

message Predicate {
  optional int64 id = 1;

  message Combination {
    optional LogicalOperation operation = 1;

    repeated int64 predicate = 2;
  }

  oneof contents {
    SimplePredicate simple_predicate = 2;
    Combination combination = 3;
  }
}

message StateMap {
  message StateGroup {
    optional int64 group_id = 1;

    repeated int32 value = 2;
  }

  repeated StateGroup group = 1;
}

message State {
  optional int64 id = 1;

  optional int32 atom_id = 2;

  optional StateMap map = 3;
}

message MetricConditionLink {
  optional int64 condition = 1;

  optional FieldMatcher fields_in_what = 2;

  optional FieldMatcher fields_in_condition = 3;
}

message MetricStateLink {
  optional int32 state_atom_id = 1;

  optional FieldMatcher fields_in_what = 2;

  optional FieldMatcher fields_in_state = 3;
}

message FieldFilter {
  optional bool include_all = 1 [default = false];
  optional FieldMatcher fields = 2;
}

message EventMetric {
  optional int64 id = 1;

  optional int64 what = 2;

  optional int64 condition = 3;

  repeated MetricConditionLink links = 4;

  reserved 100;
  reserved 101;
}

message CountMetric {
  optional int64 id = 1;

  optional int64 what = 2;

  optional int64 condition = 3;

  optional FieldMatcher dimensions_in_what = 4;

  repeated int64 slice_by_state = 8;

  optional TimeUnit bucket = 5;

  repeated MetricConditionLink links = 6;

  repeated MetricStateLink state_link = 9;

  optional FieldMatcher dimensions_in_condition = 7 [deprecated = true];

  reserved 100;
  reserved 101;
}

message DurationMetric {
  optional int64 id = 1;

  optional int64 what = 2;

  optional int64 condition = 3;

  repeated int64 slice_by_state = 9;

  repeated MetricConditionLink links = 4;

  repeated MetricStateLink state_link = 10;

  enum AggregationType {
    SUM = 1;

    MAX_SPARSE = 2;
  }
  optional AggregationType aggregation_type = 5 [default = SUM];

  optional FieldMatcher dimensions_in_what = 6;

  optional TimeUnit bucket = 7;

  optional FieldMatcher dimensions_in_condition = 8 [deprecated = true];

  reserved 100;
  reserved 101;
}

message GaugeMetric {
  optional int64 id = 1;

  optional int64 what = 2;

  optional int64 trigger_event = 12;

  optional FieldFilter gauge_fields_filter = 3;

  optional int64 condition = 4;

  optional FieldMatcher dimensions_in_what = 5;

  optional FieldMatcher dimensions_in_condition = 8 [deprecated = true];

  optional TimeUnit bucket = 6;

  repeated MetricConditionLink links = 7;

  enum SamplingType {
    RANDOM_ONE_SAMPLE = 1;
    ALL_CONDITION_CHANGES = 2 [deprecated = true];
    CONDITION_CHANGE_TO_TRUE = 3;
    FIRST_N_SAMPLES = 4;
  }
  optional SamplingType sampling_type = 9 [default = RANDOM_ONE_SAMPLE] ;

  optional int64 min_bucket_size_nanos = 10;

  optional int64 max_num_gauge_atoms_per_bucket = 11 [default = 10];

  optional int32 max_pull_delay_sec = 13 [default = 30];

  optional bool split_bucket_for_app_upgrade = 14 [default = true];

  reserved 100;
  reserved 101;
}

message ValueMetric {
  optional int64 id = 1;

  optional int64 what = 2;

  optional FieldMatcher value_field = 3;

  optional int64 condition = 4;

  optional FieldMatcher dimensions_in_what = 5;

  repeated int64 slice_by_state = 18;

  optional TimeUnit bucket = 6;

  repeated MetricConditionLink links = 7;

  repeated MetricStateLink state_link = 19;

  enum AggregationType {
    SUM = 1;
    MIN = 2;
    MAX = 3;
    AVG = 4;
  }
  optional AggregationType aggregation_type = 8 [default = SUM];

  optional int64 min_bucket_size_nanos = 10;

  optional bool use_absolute_value_on_reset = 11 [default = false];

  optional bool use_diff = 12;

  optional bool use_zero_default_base = 15 [default = false];

  enum ValueDirection {
      UNKNOWN = 0;
      INCREASING = 1;
      DECREASING = 2;
      ANY = 3;
  }
  optional ValueDirection value_direction = 13 [default = INCREASING];

  optional bool skip_zero_diff_output = 14 [default = true];

  optional int32 max_pull_delay_sec = 16 [default = 30];

  optional bool split_bucket_for_app_upgrade = 17 [default = true];

  optional FieldMatcher dimensions_in_condition = 9 [deprecated = true];

  reserved 100;
  reserved 101;
}

message Alert {
  optional int64 id = 1;

  optional int64 metric_id = 2;

  optional int32 num_buckets = 3;

  optional int32 refractory_period_secs = 4;

  optional double trigger_if_sum_gt = 5;
}

message Alarm {
  optional int64 id = 1;

  optional int64 offset_millis = 2;

  optional int64 period_millis = 3;
}

message IncidentdDetails {
  repeated int32 section = 1;

  enum Destination {
    AUTOMATIC = 0;
    EXPLICIT = 1;
  }
  optional Destination dest = 2;

  // Package name of the incident report receiver.
  optional string receiver_pkg = 3;

  // Class name of the incident report receiver.
  optional string receiver_cls = 4;

  optional string alert_description = 5;
}

message PerfettoDetails {
  // The |trace_config| field is a proto-encoded message of type
  // perfetto.protos.TraceConfig defined in
  // //external/perfetto/protos/perfetto/config/. On device,
  // statsd doesn't need to deserialize the message as it's just
  // passed binary-encoded to the perfetto cmdline client.
  optional bytes trace_config = 1;
}

message BroadcastSubscriberDetails {
  optional int64 subscriber_id = 1;
  repeated string cookie = 2;
}

message Subscription {
  optional int64 id = 1;

  enum RuleType {
    RULE_TYPE_UNSPECIFIED = 0;
    ALARM = 1;
    ALERT = 2;
  }
  optional RuleType rule_type = 2;

  optional int64 rule_id = 3;

  oneof subscriber_information {
    IncidentdDetails incidentd_details = 4;
    PerfettoDetails perfetto_details = 5;
    BroadcastSubscriberDetails broadcast_subscriber_details = 6;
  }

  optional float probability_of_informing = 7 [default = 1.1];

  // This was used for perfprofd historically.
  reserved 8;
}

enum ActivationType {
  ACTIVATION_TYPE_UNKNOWN = 0;
  ACTIVATE_IMMEDIATELY = 1;
  ACTIVATE_ON_BOOT = 2;
}

message EventActivation {
  optional int64 atom_matcher_id = 1;
  optional int64 ttl_seconds = 2;
  optional int64 deactivation_atom_matcher_id = 3;
  optional ActivationType activation_type = 4;
}

message MetricActivation {
  optional int64 metric_id = 1;

  optional ActivationType activation_type = 3 [deprecated = true];

  repeated EventActivation event_activation = 2;
}

message PullAtomPackages {
    optional int32 atom_id = 1;

    repeated string packages = 2;
}

message StatsdConfig {
  optional int64 id = 1;

  repeated EventMetric event_metric = 2;

  repeated CountMetric count_metric = 3;

  repeated ValueMetric value_metric = 4;

  repeated GaugeMetric gauge_metric = 5;

  repeated DurationMetric duration_metric = 6;

  repeated AtomMatcher atom_matcher = 7;

  repeated Predicate predicate = 8;

  repeated Alert alert = 9;

  repeated Alarm alarm = 10;

  repeated Subscription subscription = 11;

  repeated string allowed_log_source = 12;

  repeated int64 no_report_metric = 13;

  message Annotation {
    optional int64 field_int64 = 1;
    optional int32 field_int32 = 2;
  }
  repeated Annotation annotation = 14;

  optional int64 ttl_in_seconds = 15;

  optional bool hash_strings_in_metric_report = 16 [default = true];

  repeated MetricActivation metric_activation = 17;

  optional bool version_strings_in_metric_report = 18;

  optional bool installer_in_metric_report = 19;

  optional bool persist_locally = 20 [default = false];

  repeated State state = 21;

  repeated string default_pull_packages = 22;

  repeated PullAtomPackages pull_atom_packages = 23;

  repeated int32 whitelisted_atom_ids = 24;

  // Field number 1000 is reserved for later use.
  reserved 1000;
}