blob: dfcca0ca7b6cdab091028b215dc9c610a8469cd1 [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
syntax = "proto3";
package cobalt.local_aggregation;
import "src/pb/common.proto";
message GlobalAggregates {
// Map from the customer ID to all the aggregates stored for that customer.
map<uint32, DeprecatedCustomerAggregates> DEPRECATED_by_customer_id = 1;
repeated MetricAggregateEntry metric_aggregates = 3;
// A cache of all of the filtered system profiles currently referenced in the
// aggregate data.
FilteredSystemProfiles filtered_system_profiles = 2;
}
message MetricAggregateEntry {
uint32 customer_id = 1;
uint32 project_id = 2;
uint32 metric_id = 3;
MetricAggregate aggregate = 4;
}
message FilteredSystemProfiles {
// Mapping of the Farmhash Fingerprint64 of the serialized filtered
// SystemProfile, to the stored system profile.
map<uint64, SystemProfile> by_system_profile_hash = 1;
}
// All of the aggregate data for one customer.
message DeprecatedCustomerAggregates {
// A map of the customer's project ID to all the aggregates stored for that
// project.
map<uint32, DeprecatedProjectAggregates> DEPRECATED_by_project_id = 1;
}
// All of the aggregate data for one project.
message DeprecatedProjectAggregates {
// A map of the project's metric ID to all the aggregates stored for that
// metric.
map<uint32, MetricAggregate> DEPRECATED_by_metric_id = 1;
}
// All of the aggregate data for one metric.
message MetricAggregate {
uint32 version = 1;
// A map of the metric's report ID to all the aggregates stored for that
// report.
map<uint32, ReportAggregate> by_report_id = 2;
// DEPRECATED: Map from SystemProfile to report aggregates
repeated DeprecatedSystemProfileAggregate DEPRECATED_by_system_profile = 3;
}
message DeprecatedSystemProfileAggregate {
reserved 1, 2;
reserved "profile", "by_report_id";
}
// All of the aggregate data for one report.
message ReportAggregate {
oneof time_period {
DailyAggregate daily = 1;
HourlyAggregate hourly = 2;
}
}
// All of the aggregate data for one report that uses a daily aggregation
// period.
message DailyAggregate {
// Map from day_index to the aggregate data for that single day.
map<uint32, AggregationPeriodBucket> by_day_index = 1;
// The last day index this report has generated observations for
uint32 last_day_index = 2;
}
// All of the aggregate data for one report that uses an hourly aggregation
// period.
message HourlyAggregate {
// Map from hour_id to the aggregate data for that single hour.
map<uint32, AggregationPeriodBucket> by_hour_id = 1;
// The last hour id this report has generated observations for
uint32 last_hour_id = 2;
}
// The aggregate data stored for a single aggregation period's time bucket. For
// hourly reports, this will be all the data for a single hour. For daily
// reports, this will be the data for a single day of the (possibly multi-day)
// aggregation period.
message AggregationPeriodBucket {
reserved 1, 3;
// DEPRECATED: use by_event_code in the appropriate SystemProfileAggregate.
repeated EventCodesAggregateData deprecated_by_event_code = 4;
// Used for metrics of type STRING only. The list is append only, as the
// indexes into the list appear below in the StringHistogram.histogram map.
// This list should not exceed string_buffer_max entries per aggregation
// period bucket.
// WARNING: for multi-day aggregation periods, more than string_buffer_max
// entries may be stored in different buckets for days that make up the
// aggregation period. Apply string_buffer_max limits to the combination of
// all the string_hashes found in all the aggregation period buckets.
//
// Only one of `string_hashes` or `string_hashes_ff64` should be used.
//
// TODO(b/321745113): Deprecate string_hashes after Cobalt local aggregation supports
// `string_hashes_ff64`.
repeated bytes string_hashes = 2;
// Used for metrics of type STRING only. The list is append only, as the
// indexes into the list appear below in the StringHistogram.histogram map.
// This list should not exceed string_buffer_max entries per aggregation
// period bucket.
// WARNING: for multi-day aggregation periods, more than string_buffer_max
// entries may be stored in different buckets for days that make up the
// aggregation period. Apply string_buffer_max limits to the combination of
// all the string_hashes found in all the aggregation period buckets.
//
// Only one of `string_hashes` or `string_hashes_ff64` should be used.
//
// Note, Cobalt local aggregation does not yet support this field and it shouldn't be
// used.
repeated bytes string_hashes_ff64 = 6;
// Aggregates for this report, with the filtered system profile they apply
// to. SELECT_FIRST and SELECT_LAST reports will have only a single entry.
// REPORT_ALL reports may have multiple entries.
repeated SystemProfileAggregate system_profile_aggregates = 5;
}
// The aggregate data stored for a single system profile that occurred in an
// aggregation period's bucket. For SELECT_FIRST and SELECT_LAST reports, this
// will be all the data for a single aggregation period bucket. For REPORT_ALL
// reports, there may be multiple of these aggregates in a single aggregation
// period bucket.
message SystemProfileAggregate {
// The Farmhash Fingerprint64 of the serialized filtered SystemProfile.
uint64 system_profile_hash = 1;
// The exact unix timestamps at which the SystemProfile was first and last
// seen in an event during this aggregation period bucket.
uint32 first_seen_timestamp = 2;
uint32 last_seen_timestamp = 3;
// A map from event_codes vector to the AggregateData for those event codes,
// in order of first arrival. A repeated EventCodesAggregateData is used as
// the uint32[] event codes can't be used in the key of a proto map. But this
// should be treated as a map (no duplicate event_codes).
repeated EventCodesAggregateData by_event_code = 4;
}
// All the aggregate data for a single event code, in a single aggregation
// period bucket, and for a single report and system profile.
message EventCodesAggregateData {
// Array of event codes that the aggregate data corresponds to.
repeated uint32 event_codes = 1;
// The aggregated data for the event codes.
AggregateData data = 2;
}
// Aggregated data specific to the local aggregation procedure.
message AggregateData {
oneof aggregate_data {
// Used by COUNT, COUNT_AS_INTEGER, SELECT_MOST_COMMON
uint32 count = 1;
// DEPRECATED: use the AtLeastOnce message instead.
bool deprecated_at_least_once = 2;
// Used by AT_LEAST_ONCE, SELECT_FIRST
AtLeastOnce at_least_once = 8;
// Used by SUM_AND_COUNT, MEAN
SumAndCount sum_and_count = 3;
// Used by SUM, MIN, MAX
int64 integer_value = 4;
// Used by MEDIAN, PERCENTILE_N
IntegerValues integer_values = 5;
// Used by INTEGER_HISTOGRAM
IntegerHistogram integer_histogram = 6;
// Used by STRING_HISTOGRAM
StringHistogram string_histogram = 7;
// Used by AT_LEAST_ONCE_STRING
UniqueStrings unique_strings = 9;
}
}
// Aggregates whether or not an event has occurred in the period.
message AtLeastOnce {
// Has the event occurred.
// Will always be set to true as the message would not exist otherwise.
bool at_least_once = 1;
// The last TimeInfo that was sent expeditiously. In practice, always a day
// index as only daily report types support expedited sending.
uint32 last_day_index = 2;
}
// Aggregates the sum of the values and the count of how many occurred in the
// period, to calculate a mean value.
message SumAndCount {
int64 sum = 1;
uint32 count = 2;
}
// Aggregates all of the integers that occurred in the period.
message IntegerValues {
// Integers that occurred, in the order they occurred. If an integer occurs
// multiple times, it will be in the list multiple times.
repeated int64 value = 1;
}
// Aggregates a histogram of counts of all the integers that occurred in the
// period.
message IntegerHistogram {
// A mapping from the bucket index to the count of the number of integers that
// occurred for that bucket. The bucket indices come from the definition of
// the buckets in the report definition of the registry.
map<uint32, sint64> histogram = 1;
}
// Aggregates a histogram of counts of all the strings that occurred in the
// period.
message StringHistogram {
// A mapping from the string's index in the string_hashes field of this
// period's bucket, to the count of the number of times that string occurred.
// The keys are the position of the hash of the string in the repeated
// string_hashes field. The values are how many times a string with that hash
// occurred in the period.
map<uint32, sint64> histogram = 2;
}
// Aggregates all of the unique strings that occurred in the period.
message UniqueStrings {
// A map of the string (identified by its index into the string_hashes field)
// to the information about if/when that string has been sent.
map<uint32, UniqueString> unique_strings = 1;
}
message UniqueString {
// The last TimeInfo that the string was sent. In practice, always a day
// index as only daily report types support expedited sending.
uint32 last_day_index = 1;
}