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