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 bool split_bucket_for_app_upgrade = 11 [default = true]; 237 238 optional FieldMatcher dimensions_in_condition = 7 [deprecated = true]; 239 240 reserved 100; 241 reserved 101; 242} 243 244message DurationMetric { 245 optional int64 id = 1; 246 247 optional int64 what = 2; 248 249 optional int64 condition = 3; 250 251 repeated int64 slice_by_state = 9; 252 253 repeated MetricConditionLink links = 4; 254 255 repeated MetricStateLink state_link = 10; 256 257 enum AggregationType { 258 SUM = 1; 259 260 MAX_SPARSE = 2; 261 } 262 optional AggregationType aggregation_type = 5 [default = SUM]; 263 264 optional FieldMatcher dimensions_in_what = 6; 265 266 optional TimeUnit bucket = 7; 267 268 optional UploadThreshold threshold = 11; 269 270 optional bool split_bucket_for_app_upgrade = 12 [default = true]; 271 272 optional FieldMatcher dimensions_in_condition = 8 [deprecated = true]; 273 274 reserved 100; 275 reserved 101; 276} 277 278message GaugeMetric { 279 optional int64 id = 1; 280 281 optional int64 what = 2; 282 283 optional int64 trigger_event = 12; 284 285 optional FieldFilter gauge_fields_filter = 3; 286 287 optional int64 condition = 4; 288 289 optional FieldMatcher dimensions_in_what = 5; 290 291 optional FieldMatcher dimensions_in_condition = 8 [deprecated = true]; 292 293 optional TimeUnit bucket = 6; 294 295 repeated MetricConditionLink links = 7; 296 297 enum SamplingType { 298 RANDOM_ONE_SAMPLE = 1; 299 ALL_CONDITION_CHANGES = 2 [deprecated = true]; 300 CONDITION_CHANGE_TO_TRUE = 3; 301 FIRST_N_SAMPLES = 4; 302 } 303 optional SamplingType sampling_type = 9 [default = RANDOM_ONE_SAMPLE] ; 304 305 optional int64 min_bucket_size_nanos = 10; 306 307 optional int64 max_num_gauge_atoms_per_bucket = 11 [default = 10]; 308 309 optional int32 max_pull_delay_sec = 13 [default = 30]; 310 311 optional bool split_bucket_for_app_upgrade = 14 [default = true]; 312 313 reserved 100; 314 reserved 101; 315} 316 317message ValueMetric { 318 optional int64 id = 1; 319 320 optional int64 what = 2; 321 322 optional FieldMatcher value_field = 3; 323 324 optional int64 condition = 4; 325 326 optional FieldMatcher dimensions_in_what = 5; 327 328 repeated int64 slice_by_state = 18; 329 330 optional TimeUnit bucket = 6; 331 332 repeated MetricConditionLink links = 7; 333 334 repeated MetricStateLink state_link = 19; 335 336 optional UploadThreshold threshold = 20; 337 338 enum AggregationType { 339 SUM = 1; 340 MIN = 2; 341 MAX = 3; 342 AVG = 4; 343 } 344 optional AggregationType aggregation_type = 8 [default = SUM]; 345 346 optional int64 min_bucket_size_nanos = 10; 347 348 optional bool use_absolute_value_on_reset = 11 [default = false]; 349 350 optional bool use_diff = 12; 351 352 optional bool use_zero_default_base = 15 [default = false]; 353 354 enum ValueDirection { 355 UNKNOWN = 0; 356 INCREASING = 1; 357 DECREASING = 2; 358 ANY = 3; 359 } 360 optional ValueDirection value_direction = 13 [default = INCREASING]; 361 362 optional bool skip_zero_diff_output = 14 [default = true]; 363 364 optional int32 max_pull_delay_sec = 16 [default = 30]; 365 366 optional bool split_bucket_for_app_upgrade = 17 [default = true]; 367 368 optional FieldMatcher dimensions_in_condition = 9 [deprecated = true]; 369 370 reserved 100; 371 reserved 101; 372} 373 374message Alert { 375 optional int64 id = 1; 376 377 optional int64 metric_id = 2; 378 379 optional int32 num_buckets = 3; 380 381 optional int32 refractory_period_secs = 4; 382 383 optional double trigger_if_sum_gt = 5; 384} 385 386message Alarm { 387 optional int64 id = 1; 388 389 optional int64 offset_millis = 2; 390 391 optional int64 period_millis = 3; 392} 393 394message IncidentdDetails { 395 repeated int32 section = 1; 396 397 enum Destination { 398 AUTOMATIC = 0; 399 EXPLICIT = 1; 400 } 401 optional Destination dest = 2; 402 403 // Package name of the incident report receiver. 404 optional string receiver_pkg = 3; 405 406 // Class name of the incident report receiver. 407 optional string receiver_cls = 4; 408 409 optional string alert_description = 5; 410} 411 412message PerfettoDetails { 413 // The |trace_config| field is a proto-encoded message of type 414 // perfetto.protos.TraceConfig defined in 415 // //external/perfetto/protos/perfetto/config/. On device, 416 // statsd doesn't need to deserialize the message as it's just 417 // passed binary-encoded to the perfetto cmdline client. 418 optional bytes trace_config = 1; 419} 420 421message BroadcastSubscriberDetails { 422 optional int64 subscriber_id = 1; 423 repeated string cookie = 2; 424} 425 426message Subscription { 427 optional int64 id = 1; 428 429 enum RuleType { 430 RULE_TYPE_UNSPECIFIED = 0; 431 ALARM = 1; 432 ALERT = 2; 433 } 434 optional RuleType rule_type = 2; 435 436 optional int64 rule_id = 3; 437 438 oneof subscriber_information { 439 IncidentdDetails incidentd_details = 4; 440 PerfettoDetails perfetto_details = 5; 441 BroadcastSubscriberDetails broadcast_subscriber_details = 6; 442 } 443 444 optional float probability_of_informing = 7 [default = 1.1]; 445 446 // This was used for perfprofd historically. 447 reserved 8; 448} 449 450enum ActivationType { 451 ACTIVATION_TYPE_UNKNOWN = 0; 452 ACTIVATE_IMMEDIATELY = 1; 453 ACTIVATE_ON_BOOT = 2; 454} 455 456message EventActivation { 457 optional int64 atom_matcher_id = 1; 458 optional int64 ttl_seconds = 2; 459 optional int64 deactivation_atom_matcher_id = 3; 460 optional ActivationType activation_type = 4; 461} 462 463message MetricActivation { 464 optional int64 metric_id = 1; 465 466 optional ActivationType activation_type = 3 [deprecated = true]; 467 468 repeated EventActivation event_activation = 2; 469} 470 471message PullAtomPackages { 472 optional int32 atom_id = 1; 473 474 repeated string packages = 2; 475} 476 477message StatsdConfig { 478 optional int64 id = 1; 479 480 repeated EventMetric event_metric = 2; 481 482 repeated CountMetric count_metric = 3; 483 484 repeated ValueMetric value_metric = 4; 485 486 repeated GaugeMetric gauge_metric = 5; 487 488 repeated DurationMetric duration_metric = 6; 489 490 repeated AtomMatcher atom_matcher = 7; 491 492 repeated Predicate predicate = 8; 493 494 repeated Alert alert = 9; 495 496 repeated Alarm alarm = 10; 497 498 repeated Subscription subscription = 11; 499 500 repeated string allowed_log_source = 12; 501 502 repeated int64 no_report_metric = 13; 503 504 message Annotation { 505 optional int64 field_int64 = 1; 506 optional int32 field_int32 = 2; 507 } 508 repeated Annotation annotation = 14; 509 510 optional int64 ttl_in_seconds = 15; 511 512 optional bool hash_strings_in_metric_report = 16 [default = true]; 513 514 repeated MetricActivation metric_activation = 17; 515 516 optional bool version_strings_in_metric_report = 18; 517 518 optional bool installer_in_metric_report = 19; 519 520 optional bool persist_locally = 20 [default = false]; 521 522 repeated State state = 21; 523 524 repeated string default_pull_packages = 22; 525 526 repeated PullAtomPackages pull_atom_packages = 23; 527 528 repeated int32 whitelisted_atom_ids = 24; 529 530 // Field number 1000 is reserved for later use. 531 reserved 1000; 532} 533