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 optional InitialValue initial_value = 5 [default = UNKNOWN]; 135 136 optional FieldMatcher dimensions = 6; 137} 138 139message Predicate { 140 optional int64 id = 1; 141 142 message Combination { 143 optional LogicalOperation operation = 1; 144 145 repeated int64 predicate = 2; 146 } 147 148 oneof contents { 149 SimplePredicate simple_predicate = 2; 150 Combination combination = 3; 151 } 152} 153 154message StateMap { 155 message StateGroup { 156 optional int64 group_id = 1; 157 158 repeated int32 value = 2; 159 } 160 161 repeated StateGroup group = 1; 162} 163 164message State { 165 optional int64 id = 1; 166 167 optional int32 atom_id = 2; 168 169 optional StateMap map = 3; 170} 171 172message MetricConditionLink { 173 optional int64 condition = 1; 174 175 optional FieldMatcher fields_in_what = 2; 176 177 optional FieldMatcher fields_in_condition = 3; 178} 179 180message MetricStateLink { 181 optional int32 state_atom_id = 1; 182 183 optional FieldMatcher fields_in_what = 2; 184 185 optional FieldMatcher fields_in_state = 3; 186} 187 188message FieldFilter { 189 optional bool include_all = 1 [default = false]; 190 optional FieldMatcher fields = 2; 191} 192 193message UploadThreshold { 194 oneof value_comparison { 195 int64 lt_int = 1; 196 int64 gt_int = 2; 197 float lt_float = 3; 198 float gt_float = 4; 199 int64 lte_int = 5; 200 int64 gte_int = 6; 201 } 202} 203 204message EventMetric { 205 optional int64 id = 1; 206 207 optional int64 what = 2; 208 209 optional int64 condition = 3; 210 211 repeated MetricConditionLink links = 4; 212 213 reserved 100; 214 reserved 101; 215} 216 217message CountMetric { 218 optional int64 id = 1; 219 220 optional int64 what = 2; 221 222 optional int64 condition = 3; 223 224 optional FieldMatcher dimensions_in_what = 4; 225 226 repeated int64 slice_by_state = 8; 227 228 optional TimeUnit bucket = 5; 229 230 repeated MetricConditionLink links = 6; 231 232 repeated MetricStateLink state_link = 9; 233 234 optional UploadThreshold threshold = 10; 235 236 optional FieldMatcher dimensions_in_condition = 7 [deprecated = true]; 237 238 reserved 100; 239 reserved 101; 240} 241 242message DurationMetric { 243 optional int64 id = 1; 244 245 optional int64 what = 2; 246 247 optional int64 condition = 3; 248 249 repeated int64 slice_by_state = 9; 250 251 repeated MetricConditionLink links = 4; 252 253 repeated MetricStateLink state_link = 10; 254 255 enum AggregationType { 256 SUM = 1; 257 258 MAX_SPARSE = 2; 259 } 260 optional AggregationType aggregation_type = 5 [default = SUM]; 261 262 optional FieldMatcher dimensions_in_what = 6; 263 264 optional TimeUnit bucket = 7; 265 266 optional UploadThreshold threshold = 11; 267 268 optional FieldMatcher dimensions_in_condition = 8 [deprecated = true]; 269 270 reserved 100; 271 reserved 101; 272} 273 274message GaugeMetric { 275 optional int64 id = 1; 276 277 optional int64 what = 2; 278 279 optional int64 trigger_event = 12; 280 281 optional FieldFilter gauge_fields_filter = 3; 282 283 optional int64 condition = 4; 284 285 optional FieldMatcher dimensions_in_what = 5; 286 287 optional FieldMatcher dimensions_in_condition = 8 [deprecated = true]; 288 289 optional TimeUnit bucket = 6; 290 291 repeated MetricConditionLink links = 7; 292 293 enum SamplingType { 294 RANDOM_ONE_SAMPLE = 1; 295 ALL_CONDITION_CHANGES = 2 [deprecated = true]; 296 CONDITION_CHANGE_TO_TRUE = 3; 297 FIRST_N_SAMPLES = 4; 298 } 299 optional SamplingType sampling_type = 9 [default = RANDOM_ONE_SAMPLE] ; 300 301 optional int64 min_bucket_size_nanos = 10; 302 303 optional int64 max_num_gauge_atoms_per_bucket = 11 [default = 10]; 304 305 optional int32 max_pull_delay_sec = 13 [default = 30]; 306 307 optional bool split_bucket_for_app_upgrade = 14 [default = true]; 308 309 reserved 100; 310 reserved 101; 311} 312 313message ValueMetric { 314 optional int64 id = 1; 315 316 optional int64 what = 2; 317 318 optional FieldMatcher value_field = 3; 319 320 optional int64 condition = 4; 321 322 optional FieldMatcher dimensions_in_what = 5; 323 324 repeated int64 slice_by_state = 18; 325 326 optional TimeUnit bucket = 6; 327 328 repeated MetricConditionLink links = 7; 329 330 repeated MetricStateLink state_link = 19; 331 332 optional UploadThreshold threshold = 20; 333 334 enum AggregationType { 335 SUM = 1; 336 MIN = 2; 337 MAX = 3; 338 AVG = 4; 339 } 340 optional AggregationType aggregation_type = 8 [default = SUM]; 341 342 optional int64 min_bucket_size_nanos = 10; 343 344 optional bool use_absolute_value_on_reset = 11 [default = false]; 345 346 optional bool use_diff = 12; 347 348 optional bool use_zero_default_base = 15 [default = false]; 349 350 enum ValueDirection { 351 UNKNOWN = 0; 352 INCREASING = 1; 353 DECREASING = 2; 354 ANY = 3; 355 } 356 optional ValueDirection value_direction = 13 [default = INCREASING]; 357 358 optional bool skip_zero_diff_output = 14 [default = true]; 359 360 optional int32 max_pull_delay_sec = 16 [default = 30]; 361 362 optional bool split_bucket_for_app_upgrade = 17 [default = true]; 363 364 optional FieldMatcher dimensions_in_condition = 9 [deprecated = true]; 365 366 reserved 100; 367 reserved 101; 368} 369 370message Alert { 371 optional int64 id = 1; 372 373 optional int64 metric_id = 2; 374 375 optional int32 num_buckets = 3; 376 377 optional int32 refractory_period_secs = 4; 378 379 optional double trigger_if_sum_gt = 5; 380} 381 382message Alarm { 383 optional int64 id = 1; 384 385 optional int64 offset_millis = 2; 386 387 optional int64 period_millis = 3; 388} 389 390message IncidentdDetails { 391 repeated int32 section = 1; 392 393 enum Destination { 394 AUTOMATIC = 0; 395 EXPLICIT = 1; 396 } 397 optional Destination dest = 2; 398 399 // Package name of the incident report receiver. 400 optional string receiver_pkg = 3; 401 402 // Class name of the incident report receiver. 403 optional string receiver_cls = 4; 404 405 optional string alert_description = 5; 406} 407 408message PerfettoDetails { 409 // The |trace_config| field is a proto-encoded message of type 410 // perfetto.protos.TraceConfig defined in 411 // //external/perfetto/protos/perfetto/config/. On device, 412 // statsd doesn't need to deserialize the message as it's just 413 // passed binary-encoded to the perfetto cmdline client. 414 optional bytes trace_config = 1; 415} 416 417message BroadcastSubscriberDetails { 418 optional int64 subscriber_id = 1; 419 repeated string cookie = 2; 420} 421 422message Subscription { 423 optional int64 id = 1; 424 425 enum RuleType { 426 RULE_TYPE_UNSPECIFIED = 0; 427 ALARM = 1; 428 ALERT = 2; 429 } 430 optional RuleType rule_type = 2; 431 432 optional int64 rule_id = 3; 433 434 oneof subscriber_information { 435 IncidentdDetails incidentd_details = 4; 436 PerfettoDetails perfetto_details = 5; 437 BroadcastSubscriberDetails broadcast_subscriber_details = 6; 438 } 439 440 optional float probability_of_informing = 7 [default = 1.1]; 441 442 // This was used for perfprofd historically. 443 reserved 8; 444} 445 446enum ActivationType { 447 ACTIVATION_TYPE_UNKNOWN = 0; 448 ACTIVATE_IMMEDIATELY = 1; 449 ACTIVATE_ON_BOOT = 2; 450} 451 452message EventActivation { 453 optional int64 atom_matcher_id = 1; 454 optional int64 ttl_seconds = 2; 455 optional int64 deactivation_atom_matcher_id = 3; 456 optional ActivationType activation_type = 4; 457} 458 459message MetricActivation { 460 optional int64 metric_id = 1; 461 462 optional ActivationType activation_type = 3 [deprecated = true]; 463 464 repeated EventActivation event_activation = 2; 465} 466 467message PullAtomPackages { 468 optional int32 atom_id = 1; 469 470 repeated string packages = 2; 471} 472 473message StatsdConfig { 474 optional int64 id = 1; 475 476 repeated EventMetric event_metric = 2; 477 478 repeated CountMetric count_metric = 3; 479 480 repeated ValueMetric value_metric = 4; 481 482 repeated GaugeMetric gauge_metric = 5; 483 484 repeated DurationMetric duration_metric = 6; 485 486 repeated AtomMatcher atom_matcher = 7; 487 488 repeated Predicate predicate = 8; 489 490 repeated Alert alert = 9; 491 492 repeated Alarm alarm = 10; 493 494 repeated Subscription subscription = 11; 495 496 repeated string allowed_log_source = 12; 497 498 repeated int64 no_report_metric = 13; 499 500 message Annotation { 501 optional int64 field_int64 = 1; 502 optional int32 field_int32 = 2; 503 } 504 repeated Annotation annotation = 14; 505 506 optional int64 ttl_in_seconds = 15; 507 508 optional bool hash_strings_in_metric_report = 16 [default = true]; 509 510 repeated MetricActivation metric_activation = 17; 511 512 optional bool version_strings_in_metric_report = 18; 513 514 optional bool installer_in_metric_report = 19; 515 516 optional bool persist_locally = 20 [default = false]; 517 518 repeated State state = 21; 519 520 repeated string default_pull_packages = 22; 521 522 repeated PullAtomPackages pull_atom_packages = 23; 523 524 repeated int32 whitelisted_atom_ids = 24; 525 526 // Field number 1000 is reserved for later use. 527 reserved 1000; 528} 529