-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
constants.go
141 lines (122 loc) · 5.25 KB
/
constants.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.
package gcp
import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
const (
// ModuleName in Metricbeat
ModuleName = "gcp"
// MonitoringMetricsSamplingRate (in second) refers to how frequent monitoring collects measurement in GCP.
MonitoringMetricsSamplingRate = 60
)
// Metricsets / GCP services names
// NOTE: if you are adding a service make sure to update tests in metrics/metrics_requester_test.go.
const (
ServiceCloudFunctions = "cloudfunctions"
ServiceCompute = "compute"
ServiceGKE = "gke"
ServiceLoadBalancing = "loadbalancing"
ServicePubsub = "pubsub"
ServiceStorage = "storage"
ServiceFirestore = "firestore"
ServiceDataproc = "dataproc"
ServiceCloudSQL = "cloudsql"
ServiceRedis = "redis"
)
// Paths within the GCP monitoring.TimeSeries response, if converted to JSON, where you can find each ECS field required for the output event
const (
TimeSeriesResponsePathForECSAvailabilityZone = "zone"
TimeSeriesResponsePathForECSAccountID = "project_id"
TimeSeriesResponsePathForECSInstanceID = "instance_id"
TimeSeriesResponsePathForECSInstanceName = "instance_name"
)
// ECS Fields that are being captured from responses
const (
//Cloud fields https://www.elastic.co/guide/en/ecs/master/ecs-cloud.html
ECSCloud = "cloud"
ECSCloudAvailabilityZone = "availability_zone"
ECSCloudProvider = "provider"
ECSCloudRegion = "region"
ECSCloudAccount = "account"
ECSCloudAccountID = "id"
ECSCloudAccountName = "name"
ECSCloudInstance = "instance"
ECSCloudInstanceKey = ECSCloud + "." + ECSCloudInstance
ECSCloudInstanceID = "id"
ECSCloudInstanceIDKey = ECSCloudInstanceKey + "." + ECSCloudInstanceID
ECSCloudInstanceName = "name"
ECSCloudInstanceNameKey = ECSCloudInstanceKey + "." + ECSCloudInstanceName
ECSCloudMachine = "machine"
ECSCloudMachineKey = ECSCloud + "." + ECSCloudMachine
ECSCloudMachineType = "type"
ECSCloudMachineTypeKey = ECSCloudMachineKey + "." + ECSCloudMachineType
)
// Metadata keys used for events. They follow GCP structure.
const (
//Stackdriver
LabelMetrics = "metrics"
LabelResource = "resource"
LabelSystem = "system"
LabelUserMetadata = "metadata.user"
KeyTimestamp = "timestamp"
// Compute
LabelUser = "user"
LabelMetadata = "metadata"
)
// NOTE: if you are adding labels make sure to update tests in metrics/metrics_requester_test.go.
const (
DefaultResourceLabel = "resource.label.zone"
ComputeResourceLabel = "resource.labels.zone"
GKEResourceLabel = "resource.label.location"
StorageResourceLabel = "resource.label.location"
CloudSQLResourceLabel = "resource.labels.region"
DataprocResourceLabel = "resource.label.region"
RedisResourceLabel = "resource.label.region"
)
// AlignersMapToGCP map contains available perSeriesAligner
// https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.alertPolicies#Aligner
var AlignersMapToGCP = map[string]monitoringpb.Aggregation_Aligner{
"ALIGN_NONE": monitoringpb.Aggregation_ALIGN_NONE,
"ALIGN_DELTA": monitoringpb.Aggregation_ALIGN_DELTA,
"ALIGN_RATE": monitoringpb.Aggregation_ALIGN_RATE,
"ALIGN_INTERPOLATE": monitoringpb.Aggregation_ALIGN_INTERPOLATE,
"ALIGN_NEXT_OLDER": monitoringpb.Aggregation_ALIGN_NEXT_OLDER,
"ALIGN_MIN": monitoringpb.Aggregation_ALIGN_MIN,
"ALIGN_MAX": monitoringpb.Aggregation_ALIGN_MAX,
"ALIGN_MEAN": monitoringpb.Aggregation_ALIGN_MEAN,
"ALIGN_COUNT": monitoringpb.Aggregation_ALIGN_COUNT,
"ALIGN_SUM": monitoringpb.Aggregation_ALIGN_SUM,
"ALIGN_STDDEV": monitoringpb.Aggregation_ALIGN_STDDEV,
"ALIGN_COUNT_TRUE": monitoringpb.Aggregation_ALIGN_COUNT_TRUE,
"ALIGN_COUNT_FALSE": monitoringpb.Aggregation_ALIGN_COUNT_FALSE,
"ALIGN_FRACTION_TRUE": monitoringpb.Aggregation_ALIGN_FRACTION_TRUE,
"ALIGN_PERCENTILE_99": monitoringpb.Aggregation_ALIGN_PERCENTILE_99,
"ALIGN_PERCENTILE_95": monitoringpb.Aggregation_ALIGN_PERCENTILE_95,
"ALIGN_PERCENTILE_50": monitoringpb.Aggregation_ALIGN_PERCENTILE_50,
"ALIGN_PERCENTILE_05": monitoringpb.Aggregation_ALIGN_PERCENTILE_05,
"ALIGN_PERCENT_CHANGE": monitoringpb.Aggregation_ALIGN_PERCENT_CHANGE,
}
const (
DefaultAligner = "ALIGN_NONE"
)
var AlignersMapToSuffix = map[string]string{
"ALIGN_NONE": ".value",
"ALIGN_DELTA": ".delta",
"ALIGN_RATE": ".rate",
"ALIGN_INTERPOLATE": ".interpolate",
"ALIGN_NEXT_OLDER": ".next_older",
"ALIGN_MIN": ".min",
"ALIGN_MAX": ".max",
"ALIGN_MEAN": ".avg",
"ALIGN_COUNT": ".count",
"ALIGN_SUM": ".sum",
"ALIGN_STDDEV": ".stddev",
"ALIGN_COUNT_TRUE": ".count_true",
"ALIGN_COUNT_FALSE": ".count_false",
"ALIGN_FRACTION_TRUE": ".fraction_true",
"ALIGN_PERCENTILE_99": ".percentile_99",
"ALIGN_PERCENTILE_95": ".percentile_95",
"ALIGN_PERCENTILE_50": ".percentile_50",
"ALIGN_PERCENTILE_05": ".percentile_05",
"ALIGN_PERCENT_CHANGE": ".percent_change",
}