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
24import "frameworks/base/cmds/statsd/src/perfetto/perfetto_config.proto";
25
26enum Position {
27  POSITION_UNKNOWN = 0;
28
29  FIRST = 1;
30
31  LAST = 2;
32
33  ANY = 3;
34
35  ALL = 4;
36}
37
38enum TimeUnit {
39  TIME_UNIT_UNSPECIFIED = 0;
40  ONE_MINUTE = 1;
41  FIVE_MINUTES = 2;
42  TEN_MINUTES = 3;
43  THIRTY_MINUTES = 4;
44  ONE_HOUR = 5;
45  THREE_HOURS = 6;
46  SIX_HOURS = 7;
47  TWELVE_HOURS = 8;
48  ONE_DAY = 9;
49  CTS = 1000;
50}
51
52message FieldMatcher {
53  optional int32 field = 1;
54
55  optional Position position = 2;
56
57  repeated FieldMatcher child = 3;
58}
59
60message FieldValueMatcher {
61  optional int32 field = 1;
62
63  optional Position position = 2;
64
65  oneof value_matcher {
66    bool eq_bool = 3;
67    string eq_string = 4;
68    int64 eq_int = 5;
69
70    int64 lt_int = 6;
71    int64 gt_int = 7;
72    float lt_float = 8;
73    float gt_float = 9;
74
75    int64 lte_int = 10;
76    int64 gte_int = 11;
77
78    MessageMatcher matches_tuple = 12;
79
80    StringListMatcher eq_any_string = 13;
81    StringListMatcher neq_any_string = 14;
82  }
83}
84
85message MessageMatcher {
86  repeated FieldValueMatcher field_value_matcher = 1;
87}
88
89message StringListMatcher {
90    repeated string str_value = 1;
91}
92
93enum LogicalOperation {
94  LOGICAL_OPERATION_UNSPECIFIED = 0;
95  AND = 1;
96  OR = 2;
97  NOT = 3;
98  NAND = 4;
99  NOR = 5;
100}
101
102message SimpleAtomMatcher {
103  optional int32 atom_id = 1;
104
105  repeated FieldValueMatcher field_value_matcher = 2;
106}
107
108message AtomMatcher {
109  optional int64 id = 1;
110
111  message Combination {
112    optional LogicalOperation operation = 1;
113
114    repeated int64 matcher = 2;
115  }
116  oneof contents {
117    SimpleAtomMatcher simple_atom_matcher = 2;
118    Combination combination = 3;
119  }
120}
121
122message SimplePredicate {
123  optional int64 start = 1;
124
125  optional int64 stop = 2;
126
127  optional bool count_nesting = 3 [default = true];
128
129  optional int64 stop_all = 4;
130
131  enum InitialValue {
132    UNKNOWN = 0;
133    FALSE = 1;
134  }
135  optional InitialValue initial_value = 5 [default = FALSE];
136
137  optional FieldMatcher dimensions = 6;
138}
139
140message Predicate {
141  optional int64 id = 1;
142
143  message Combination {
144    optional LogicalOperation operation = 1;
145
146    repeated int64 predicate = 2;
147  }
148
149  oneof contents {
150    SimplePredicate simple_predicate = 2;
151    Combination combination = 3;
152  }
153}
154
155message MetricConditionLink {
156  optional int64 condition = 1;
157
158  optional FieldMatcher fields_in_what = 2;
159
160  optional FieldMatcher fields_in_condition = 3;
161}
162
163message FieldFilter {
164  optional bool include_all = 1 [default = false];
165  optional FieldMatcher fields = 2;
166}
167
168message EventMetric {
169  optional int64 id = 1;
170
171  optional int64 what = 2;
172
173  optional int64 condition = 3;
174
175  repeated MetricConditionLink links = 4;
176}
177
178message CountMetric {
179  optional int64 id = 1;
180
181  optional int64 what = 2;
182
183  optional int64 condition = 3;
184
185  optional FieldMatcher dimensions_in_what = 4;
186
187  optional FieldMatcher dimensions_in_condition = 7;
188
189  optional TimeUnit bucket = 5;
190
191  repeated MetricConditionLink links = 6;
192}
193
194message DurationMetric {
195  optional int64 id = 1;
196
197  optional int64 what = 2;
198
199  optional int64 condition = 3;
200
201  repeated MetricConditionLink links = 4;
202
203  enum AggregationType {
204    SUM = 1;
205
206    MAX_SPARSE = 2;
207  }
208  optional AggregationType aggregation_type = 5 [default = SUM];
209
210  optional FieldMatcher dimensions_in_what = 6;
211
212  optional FieldMatcher dimensions_in_condition = 8;
213
214  optional TimeUnit bucket = 7;
215}
216
217message GaugeMetric {
218  optional int64 id = 1;
219
220  optional int64 what = 2;
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;
237    CONDITION_CHANGE_TO_TRUE = 3;
238  }
239  optional SamplingType sampling_type = 9 [default = RANDOM_ONE_SAMPLE] ;
240
241  optional int64 min_bucket_size_nanos = 10;
242  optional int64 max_num_gauge_atoms_per_bucket = 11 [default = 10];
243}
244
245message ValueMetric {
246  optional int64 id = 1;
247
248  optional int64 what = 2;
249
250  optional FieldMatcher value_field = 3;
251
252  optional int64 condition = 4;
253
254  optional FieldMatcher dimensions_in_what = 5;
255
256  optional FieldMatcher dimensions_in_condition = 9;
257
258  optional TimeUnit bucket = 6;
259
260  repeated MetricConditionLink links = 7;
261
262  enum AggregationType {
263    SUM = 1;
264  }
265  optional AggregationType aggregation_type = 8 [default = SUM];
266
267  optional int64 min_bucket_size_nanos = 10;
268
269  optional bool use_absolute_value_on_reset = 11 [default = false];
270}
271
272message Alert {
273  optional int64 id = 1;
274
275  optional int64 metric_id = 2;
276
277  optional int32 num_buckets = 3;
278
279  optional int32 refractory_period_secs = 4;
280
281  optional double trigger_if_sum_gt = 5;
282}
283
284message Alarm {
285  optional int64 id = 1;
286
287  optional int64 offset_millis = 2;
288
289  optional int64 period_millis = 3;
290}
291
292message IncidentdDetails {
293  repeated int32 section = 1;
294
295  enum Destination {
296    AUTOMATIC = 0;
297    EXPLICIT = 1;
298  }
299  optional Destination dest = 2;
300}
301
302message PerfettoDetails {
303  optional perfetto.protos.TraceConfig trace_config = 1;
304}
305
306message BroadcastSubscriberDetails {
307  optional int64 subscriber_id = 1;
308  repeated string cookie = 2;
309}
310
311message Subscription {
312  optional int64 id = 1;
313
314  enum RuleType {
315    RULE_TYPE_UNSPECIFIED = 0;
316    ALARM = 1;
317    ALERT = 2;
318  }
319  optional RuleType rule_type = 2;
320
321  optional int64 rule_id = 3;
322
323  oneof subscriber_information {
324    IncidentdDetails incidentd_details = 4;
325    PerfettoDetails perfetto_details = 5;
326    BroadcastSubscriberDetails broadcast_subscriber_details = 6;
327  }
328
329  optional float probability_of_informing = 7 [default = 1.1];
330}
331
332message StatsdConfig {
333  optional int64 id = 1;
334
335  repeated EventMetric event_metric = 2;
336
337  repeated CountMetric count_metric = 3;
338
339  repeated ValueMetric value_metric = 4;
340
341  repeated GaugeMetric gauge_metric = 5;
342
343  repeated DurationMetric duration_metric = 6;
344
345  repeated AtomMatcher atom_matcher = 7;
346
347  repeated Predicate predicate = 8;
348
349  repeated Alert alert = 9;
350
351  repeated Alarm alarm = 10;
352
353  repeated Subscription subscription = 11;
354
355  repeated string allowed_log_source = 12;
356
357  repeated int64 no_report_metric = 13;
358
359  message Annotation {
360    optional int64 field_int64 = 1;
361    optional int32 field_int32 = 2;
362  }
363  repeated Annotation annotation = 14;
364
365  optional int64 ttl_in_seconds = 15;
366
367  optional bool hash_strings_in_metric_report = 16 [default = true];
368
369  // Field number 1000 is reserved for later use.
370  reserved 1000;
371}
372