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 optional FieldMatcher fields = 2; 217} 218 219message UploadThreshold { 220 oneof value_comparison { 221 int64 lt_int = 1; 222 int64 gt_int = 2; 223 float lt_float = 3; 224 float gt_float = 4; 225 int64 lte_int = 5; 226 int64 gte_int = 6; 227 } 228} 229 230message DimensionalSamplingInfo { 231 optional FieldMatcher sampled_what_field = 1; 232 233 optional int32 shard_count = 2; 234} 235 236message EventMetric { 237 optional int64 id = 1; 238 239 optional int64 what = 2; 240 241 optional int64 condition = 3; 242 243 repeated MetricConditionLink links = 4; 244 245 optional int32 sampling_percentage = 5 [default = 100]; 246 247 reserved 100; 248 reserved 101; 249} 250 251message CountMetric { 252 optional int64 id = 1; 253 254 optional int64 what = 2; 255 256 optional int64 condition = 3; 257 258 optional FieldMatcher dimensions_in_what = 4; 259 260 repeated int64 slice_by_state = 8; 261 262 optional TimeUnit bucket = 5; 263 264 repeated MetricConditionLink links = 6; 265 266 repeated MetricStateLink state_link = 9; 267 268 optional UploadThreshold threshold = 10; 269 270 optional bool split_bucket_for_app_upgrade = 11; 271 272 optional FieldMatcher dimensions_in_condition = 7 [deprecated = true]; 273 274 optional DimensionalSamplingInfo dimensional_sampling_info = 12; 275 276 optional int32 max_dimensions_per_bucket = 13; 277 278 reserved 100; 279 reserved 101; 280} 281 282message DurationMetric { 283 optional int64 id = 1; 284 285 optional int64 what = 2; 286 287 optional int64 condition = 3; 288 289 repeated int64 slice_by_state = 9; 290 291 repeated MetricConditionLink links = 4; 292 293 repeated MetricStateLink state_link = 10; 294 295 enum AggregationType { 296 SUM = 1; 297 298 MAX_SPARSE = 2; 299 } 300 optional AggregationType aggregation_type = 5 [default = SUM]; 301 302 optional FieldMatcher dimensions_in_what = 6; 303 304 optional TimeUnit bucket = 7; 305 306 optional UploadThreshold threshold = 11; 307 308 optional bool split_bucket_for_app_upgrade = 12; 309 310 optional FieldMatcher dimensions_in_condition = 8 [deprecated = true]; 311 312 optional DimensionalSamplingInfo dimensional_sampling_info = 13; 313 314 optional int32 max_dimensions_per_bucket = 14; 315 316 reserved 100; 317 reserved 101; 318} 319 320message GaugeMetric { 321 optional int64 id = 1; 322 323 optional int64 what = 2; 324 325 optional int64 trigger_event = 12; 326 327 optional FieldFilter gauge_fields_filter = 3; 328 329 optional int64 condition = 4; 330 331 optional FieldMatcher dimensions_in_what = 5; 332 333 optional FieldMatcher dimensions_in_condition = 8 [deprecated = true]; 334 335 optional TimeUnit bucket = 6; 336 337 repeated MetricConditionLink links = 7; 338 339 enum SamplingType { 340 RANDOM_ONE_SAMPLE = 1; 341 ALL_CONDITION_CHANGES = 2 [deprecated = true]; 342 CONDITION_CHANGE_TO_TRUE = 3; 343 FIRST_N_SAMPLES = 4; 344 } 345 optional SamplingType sampling_type = 9 [default = RANDOM_ONE_SAMPLE] ; 346 347 optional int64 min_bucket_size_nanos = 10; 348 349 optional int64 max_num_gauge_atoms_per_bucket = 11 [default = 10]; 350 351 optional int32 max_pull_delay_sec = 13 [default = 30]; 352 353 optional bool split_bucket_for_app_upgrade = 14; 354 355 optional DimensionalSamplingInfo dimensional_sampling_info = 15; 356 357 optional int32 max_dimensions_per_bucket = 16; 358 359 optional int32 sampling_percentage = 17 [default = 100]; 360 361 optional int32 pull_probability = 18 [default = 100]; 362 363 reserved 100; 364 reserved 101; 365} 366 367message HistogramBinConfig { 368 message ExplicitBins { 369 repeated float bin = 1; 370 } 371 372 message GeneratedBins { 373 enum Strategy { 374 UNKNOWN = 0; 375 LINEAR = 1; 376 EXPONENTIAL = 2; 377 } 378 379 optional float min = 1; 380 optional float max = 2; 381 optional int32 count = 3; 382 optional Strategy strategy = 4; 383 } 384 385 optional int64 id = 1; 386 oneof binning_strategy { 387 GeneratedBins generated_bins = 2; 388 ExplicitBins explicit_bins = 3; 389 } 390} 391 392message ValueMetric { 393 optional int64 id = 1; 394 395 optional int64 what = 2; 396 397 optional FieldMatcher value_field = 3; 398 399 optional int64 condition = 4; 400 401 optional FieldMatcher dimensions_in_what = 5; 402 403 repeated int64 slice_by_state = 18; 404 405 optional TimeUnit bucket = 6; 406 407 repeated MetricConditionLink links = 7; 408 409 repeated MetricStateLink state_link = 19; 410 411 optional UploadThreshold threshold = 20; 412 413 optional int64 condition_correction_threshold_nanos = 21; 414 415 enum AggregationType { 416 SUM = 1; 417 MIN = 2; 418 MAX = 3; 419 AVG = 4; 420 HISTOGRAM = 5; 421 } 422 optional AggregationType aggregation_type = 8 [default = SUM]; 423 424 repeated AggregationType aggregation_types = 25; 425 426 // The number of entries should match the number of times HISTOGRAM appears in aggregation_types. 427 // Each i'th HistogramBinConfig corresponds to the i'th HISTOGRAM entry in aggregation_types so 428 // ordering matters. 429 repeated HistogramBinConfig histogram_bin_configs = 26; 430 431 optional bool include_sample_size = 22; 432 433 optional int64 min_bucket_size_nanos = 10; 434 435 optional bool use_absolute_value_on_reset = 11 [default = false]; 436 437 optional bool use_diff = 12; 438 439 optional bool use_zero_default_base = 15 [default = false]; 440 441 enum ValueDirection { 442 UNKNOWN = 0; 443 INCREASING = 1; 444 DECREASING = 2; 445 ANY = 3; 446 } 447 optional ValueDirection value_direction = 13 [default = INCREASING]; 448 449 optional bool skip_zero_diff_output = 14 [default = true]; 450 451 optional int32 max_pull_delay_sec = 16 [default = 30]; 452 453 optional bool split_bucket_for_app_upgrade = 17; 454 455 optional FieldMatcher dimensions_in_condition = 9 [deprecated = true]; 456 457 optional DimensionalSamplingInfo dimensional_sampling_info = 23; 458 459 optional int32 max_dimensions_per_bucket = 24; 460 461 reserved 100; 462 reserved 101; 463} 464 465message KllMetric { 466 optional int64 id = 1; 467 468 optional int64 what = 2; 469 470 optional FieldMatcher kll_field = 3; 471 472 optional int64 condition = 4; 473 474 optional FieldMatcher dimensions_in_what = 5; 475 476 optional TimeUnit bucket = 6; 477 478 repeated MetricConditionLink links = 7; 479 480 optional int64 min_bucket_size_nanos = 8; 481 482 optional bool split_bucket_for_app_upgrade = 9; 483 484 repeated int64 slice_by_state = 10; 485 486 repeated MetricStateLink state_link = 11; 487 488 optional DimensionalSamplingInfo dimensional_sampling_info = 12; 489 490 optional int32 max_dimensions_per_bucket = 13; 491 492 reserved 100; 493 reserved 101; 494} 495 496message Alert { 497 optional int64 id = 1; 498 499 optional int64 metric_id = 2; 500 501 optional int32 num_buckets = 3; 502 503 optional int32 refractory_period_secs = 4; 504 505 optional double trigger_if_sum_gt = 5; 506 507 optional float probability_of_informing = 6 [default = 1.1]; 508} 509 510message Alarm { 511 optional int64 id = 1; 512 513 optional int64 offset_millis = 2; 514 515 optional int64 period_millis = 3; 516 517 optional float probability_of_informing = 4 [default = 1.1]; 518} 519 520message IncidentdDetails { 521 repeated int32 section = 1; 522 523 enum Destination { 524 AUTOMATIC = 0; 525 EXPLICIT = 1; 526 } 527 optional Destination dest = 2; 528 529 // Package name of the incident report receiver. 530 optional string receiver_pkg = 3; 531 532 // Class name of the incident report receiver. 533 optional string receiver_cls = 4; 534 535 optional string alert_description = 5; 536} 537 538message PerfettoDetails { 539 // The |trace_config| field is a proto-encoded message of type 540 // perfetto.protos.TraceConfig defined in 541 // //external/perfetto/protos/perfetto/config/. On device, 542 // statsd doesn't need to deserialize the message as it's just 543 // passed binary-encoded to the perfetto cmdline client. 544 optional bytes trace_config = 1; 545} 546 547message UprobestatsDetails { 548 // The |config| field is a proto-encoded message of type 549 // uprobestats.protos.UprobestatsConfig defined in 550 // //packages/modules/UprobeStats/src/config.proto. On device, 551 // statsd doesn't need to deserialize the message as it's just 552 // passed binary-encoded to the Uprobestats API. 553 optional bytes config = 1; 554} 555 556message BroadcastSubscriberDetails { 557 optional int64 subscriber_id = 1; 558 repeated string cookie = 2; 559} 560 561message Subscription { 562 optional int64 id = 1; 563 564 enum RuleType { 565 RULE_TYPE_UNSPECIFIED = 0; 566 ALARM = 1; 567 ALERT = 2; 568 } 569 optional RuleType rule_type = 2; 570 571 optional int64 rule_id = 3; 572 573 oneof subscriber_information { 574 IncidentdDetails incidentd_details = 4; 575 PerfettoDetails perfetto_details = 5; 576 BroadcastSubscriberDetails broadcast_subscriber_details = 6; 577 UprobestatsDetails uprobestats_details = 9; 578 } 579 580 optional float probability_of_informing = 7 [default = 1.1]; 581 582 // This was used for perfprofd historically. 583 reserved 8; 584} 585 586enum ActivationType { 587 ACTIVATION_TYPE_UNKNOWN = 0; 588 ACTIVATE_IMMEDIATELY = 1; 589 ACTIVATE_ON_BOOT = 2; 590} 591 592message EventActivation { 593 optional int64 atom_matcher_id = 1; 594 optional int64 ttl_seconds = 2; 595 optional int64 deactivation_atom_matcher_id = 3; 596 optional ActivationType activation_type = 4; 597} 598 599message MetricActivation { 600 optional int64 metric_id = 1; 601 602 optional ActivationType activation_type = 3 [deprecated = true]; 603 604 repeated EventActivation event_activation = 2; 605} 606 607message PullAtomPackages { 608 optional int32 atom_id = 1; 609 610 repeated string packages = 2; 611} 612 613message StatsdConfig { 614 optional int64 id = 1; 615 616 repeated EventMetric event_metric = 2; 617 618 repeated CountMetric count_metric = 3; 619 620 repeated ValueMetric value_metric = 4; 621 622 repeated GaugeMetric gauge_metric = 5; 623 624 repeated DurationMetric duration_metric = 6; 625 626 repeated KllMetric kll_metric = 25; 627 628 repeated AtomMatcher atom_matcher = 7; 629 630 repeated Predicate predicate = 8; 631 632 repeated Alert alert = 9; 633 634 repeated Alarm alarm = 10; 635 636 repeated Subscription subscription = 11; 637 638 repeated string allowed_log_source = 12; 639 640 repeated int64 no_report_metric = 13; 641 642 message Annotation { 643 optional int64 field_int64 = 1; 644 optional int32 field_int32 = 2; 645 } 646 repeated Annotation annotation = 14; 647 648 optional int64 ttl_in_seconds = 15; 649 650 optional bool hash_strings_in_metric_report = 16 [default = true]; 651 652 repeated MetricActivation metric_activation = 17; 653 654 optional bool version_strings_in_metric_report = 18; 655 656 optional bool installer_in_metric_report = 19; 657 658 optional bool persist_locally = 20 [default = false]; 659 660 repeated State state = 21; 661 662 repeated string default_pull_packages = 22; 663 664 repeated PullAtomPackages pull_atom_packages = 23; 665 666 repeated int32 whitelisted_atom_ids = 24; 667 668 optional uint32 package_certificate_hash_size_bytes = 26; 669 670 optional string restricted_metrics_delegate_package_name = 27; 671 672 optional int32 max_metrics_memory_kb = 28; 673 674 optional int32 soft_metrics_memory_kb = 29; 675 676 message StatsdConfigOptions { 677 optional bool use_v2_soft_memory_limit = 1; 678 optional bool omit_system_uids_in_uidmap = 2; 679 } 680 681 optional StatsdConfigOptions statsd_config_options = 30; 682 683 // Do not use. 684 reserved 1000, 1001; 685} 686