github.com/m3db/m3@v1.5.0/src/cmd/services/m3aggregator/config/defaults.go (about) 1 // Copyright (c) 2021 Uber Technologies, Inc. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 // Package config contains configuration for the aggregator. 22 package config 23 24 import ( 25 "time" 26 27 "github.com/m3db/m3/src/aggregator/aggregator/handler" 28 aggclient "github.com/m3db/m3/src/aggregator/client" 29 "github.com/m3db/m3/src/aggregator/sharding" 30 etcdclient "github.com/m3db/m3/src/cluster/client/etcd" 31 "github.com/m3db/m3/src/cluster/kv" 32 "github.com/m3db/m3/src/cluster/placement" 33 "github.com/m3db/m3/src/cluster/services" 34 "github.com/m3db/m3/src/metrics/aggregation" 35 "github.com/m3db/m3/src/msg/consumer" 36 producerconfig "github.com/m3db/m3/src/msg/producer/config" 37 "github.com/m3db/m3/src/x/config/hostid" 38 "github.com/m3db/m3/src/x/instrument" 39 "github.com/m3db/m3/src/x/log" 40 "github.com/m3db/m3/src/x/pool" 41 "github.com/m3db/m3/src/x/retry" 42 xserver "github.com/m3db/m3/src/x/server" 43 ) 44 45 // This file contains a set of sane defaults for spinning up the aggregator. 46 // This is mostly useful for spinning up an aggregator for local development 47 // or tests. 48 49 const ( 50 defaultZone = "embedded" 51 defaultEnv = "default_env" 52 defaultService = "m3aggregator" 53 defaultNamespace = "/placement" 54 ) 55 56 var ( 57 defaultLogging = log.Configuration{ 58 Level: "info", 59 } 60 defaultMetricsSanitization = instrument.PrometheusMetricSanitization 61 defaultMetricsExtendedMetricsType = instrument.NoExtendedMetrics 62 defaultMetrics = instrument.MetricsConfiguration{ 63 PrometheusReporter: &instrument.PrometheusConfiguration{ 64 OnError: "none", 65 HandlerPath: "/metrics", 66 ListenAddress: "0.0.0.0:6002", 67 TimerType: "histogram", 68 }, 69 Sanitization: &defaultMetricsSanitization, 70 SamplingRate: 1.0, 71 ExtendedMetrics: &defaultMetricsExtendedMetricsType, 72 } 73 defaultJitter = true 74 defaultM3Msg = M3MsgServerConfiguration{ 75 Server: xserver.Configuration{ 76 ListenAddress: "0.0.0.0:6000", 77 Retry: retry.Configuration{ 78 MaxBackoff: 10 * time.Second, 79 Jitter: &defaultJitter, 80 }, 81 }, 82 Consumer: consumer.Configuration{ 83 MessagePool: &consumer.MessagePoolConfiguration{ 84 Size: 16384, 85 Watermark: pool.WatermarkConfiguration{ 86 RefillLowWatermark: 0.2, 87 RefillHighWatermark: 0.5, 88 }, 89 }, 90 }, 91 } 92 defaultHTTP = HTTPServerConfiguration{ 93 ListenAddress: "0.0.0.0:6001", 94 ReadTimeout: 60 * time.Second, 95 WriteTimeout: 60 * time.Second, 96 } 97 defaultKV = KVClientConfiguration{ 98 Etcd: &etcdclient.Configuration{ 99 Zone: defaultZone, 100 Env: defaultEnv, 101 Service: defaultService, 102 CacheDir: "/var/lib/m3kv", 103 ETCDClusters: []etcdclient.ClusterConfig{ 104 { 105 Zone: defaultZone, 106 Endpoints: []string{ 107 "0.0.0.0:2379", 108 }, 109 }, 110 }, 111 }, 112 } 113 defaultEmptyPrefix = "" 114 defaultHashType = sharding.Murmur32Hash 115 defaultIsStaged = true 116 defaultForever = true 117 defaultNumCachedSourceSets = 2 118 defaultDiscardNanValues = true 119 defaultRuntimeOptions = RuntimeOptionsConfiguration{ 120 WriteValuesPerMetricLimitPerSecondKey: "write-values-per-metric-limit-per-second", 121 WriteNewMetricLimitClusterPerSecondKey: "write-new-metric-limit-cluster-per-second", 122 } 123 124 defaultAggregator = AggregatorConfiguration{ 125 HostID: &hostid.Configuration{ 126 Resolver: hostid.ConfigResolver, 127 Value: &defaultHostID, 128 }, 129 InstanceID: InstanceIDConfiguration{HostIDInstanceIDType}, 130 MetricPrefix: &defaultEmptyPrefix, 131 CounterPrefix: &defaultEmptyPrefix, 132 TimerPrefix: &defaultEmptyPrefix, 133 GaugePrefix: &defaultEmptyPrefix, 134 AggregationTypes: aggregation.TypesConfiguration{ 135 CounterTransformFnType: &aggregation.EmptyTransformType, 136 TimerTransformFnType: &aggregation.SuffixTransformType, 137 GaugeTransformFnType: &aggregation.EmptyTransformType, 138 AggregationTypesPool: pool.ObjectPoolConfiguration{ 139 Size: 1024, 140 }, 141 QuantilesPool: pool.BucketizedPoolConfiguration{ 142 Buckets: []pool.BucketConfiguration{ 143 { 144 Count: 256, 145 Capacity: 4, 146 }, 147 { 148 Count: 128, 149 Capacity: 8, 150 }, 151 }, 152 }, 153 }, 154 Stream: streamConfiguration{ 155 Eps: 0.001, 156 Capacity: 32, 157 StreamPool: pool.ObjectPoolConfiguration{Size: 4096}, 158 SamplePool: &pool.ObjectPoolConfiguration{Size: 4096}, 159 FloatsPool: pool.BucketizedPoolConfiguration{ 160 Buckets: []pool.BucketConfiguration{ 161 {Count: 4096, Capacity: 16}, 162 {Count: 2048, Capacity: 32}, 163 {Count: 1024, Capacity: 64}, 164 }, 165 }, 166 }, 167 Client: aggclient.Configuration{ 168 Type: aggclient.M3MsgAggregatorClient, 169 M3Msg: &aggclient.M3MsgConfiguration{ 170 Producer: producerconfig.ProducerConfiguration{ 171 Writer: producerconfig.WriterConfiguration{ 172 TopicName: "aggregator_ingest", 173 PlacementOptions: placement.Configuration{ 174 IsStaged: &defaultIsStaged, 175 }, 176 PlacementServiceOverride: services.OverrideConfiguration{ 177 Namespaces: services.NamespacesConfiguration{ 178 Placement: defaultNamespace, 179 }, 180 }, 181 MessagePool: &pool.ObjectPoolConfiguration{ 182 Size: 16384, 183 Watermark: pool.WatermarkConfiguration{ 184 RefillLowWatermark: 0.2, 185 RefillHighWatermark: 0.5, 186 }, 187 }, 188 }, 189 }, 190 }, 191 }, 192 PlacementManager: placementManagerConfiguration{ 193 KVConfig: kv.OverrideConfiguration{ 194 Namespace: defaultNamespace, 195 }, 196 Watcher: placement.WatcherConfiguration{ 197 Key: defaultService, 198 InitWatchTimeout: 10 * time.Second, 199 }, 200 }, 201 HashType: &defaultHashType, 202 BufferDurationBeforeShardCutover: 10 * time.Minute, 203 BufferDurationAfterShardCutoff: 10 * time.Minute, 204 BufferDurationForFutureTimedMetric: 10 * time.Minute, 205 BufferDurationForPastTimedMetric: 10 * time.Minute, 206 ResignTimeout: 1 * time.Minute, 207 FlushTimesManager: flushTimesManagerConfiguration{ 208 FlushTimesKeyFmt: "shardset/%d/flush", 209 FlushTimesPersistRetrier: retry.Configuration{ 210 InitialBackoff: 100 * time.Millisecond, 211 BackoffFactor: 2.0, 212 MaxBackoff: 2 * time.Second, 213 MaxRetries: 3, 214 }, 215 }, 216 ElectionManager: electionManagerConfiguration{ 217 Election: electionConfiguration{ 218 LeaderTimeout: 10 * time.Second, 219 ResignTimeout: 10 * time.Second, 220 TTLSeconds: 10, 221 }, 222 ServiceID: serviceIDConfiguration{ 223 Name: defaultService, 224 Environment: defaultEnv, 225 Zone: defaultZone, 226 }, 227 ElectionKeyFmt: "shardset/%d/lock", 228 CampaignRetrier: retry.Configuration{ 229 InitialBackoff: 100 * time.Millisecond, 230 BackoffFactor: 2.0, 231 MaxBackoff: 2 * time.Second, 232 Forever: &defaultForever, 233 Jitter: &defaultJitter, 234 }, 235 ChangeRetrier: retry.Configuration{ 236 InitialBackoff: 100 * time.Millisecond, 237 BackoffFactor: 2.0, 238 MaxBackoff: 5 * time.Second, 239 Forever: &defaultForever, 240 Jitter: &defaultJitter, 241 }, 242 ResignRetrier: retry.Configuration{ 243 InitialBackoff: 100 * time.Millisecond, 244 BackoffFactor: 2.0, 245 MaxBackoff: 5 * time.Second, 246 Forever: &defaultForever, 247 Jitter: &defaultJitter, 248 }, 249 CampaignStateCheckInterval: 1 * time.Second, 250 ShardCutoffCheckOffset: 30 * time.Second, 251 }, 252 FlushManager: flushManagerConfiguration{ 253 CheckEvery: 1 * time.Second, 254 JitterEnabled: &defaultJitter, 255 MaxJitters: []jitterBucket{ 256 { 257 FlushInterval: 5 * time.Second, 258 MaxJitterPercent: 1.0, 259 }, 260 { 261 FlushInterval: 10 * time.Second, 262 MaxJitterPercent: 0.5, 263 }, 264 { 265 FlushInterval: 1 * time.Minute, 266 MaxJitterPercent: 0.5, 267 }, 268 { 269 FlushInterval: 10 * time.Minute, 270 MaxJitterPercent: 0.5, 271 }, 272 { 273 FlushInterval: 1 * time.Hour, 274 MaxJitterPercent: 0.25, 275 }, 276 }, 277 NumWorkersPerCPU: 0.5, 278 MaxBufferSize: 5 * time.Minute, 279 ForcedFlushWindowSize: 10 * time.Second, 280 }, 281 Flush: handler.FlushConfiguration{ 282 Handlers: []handler.FlushHandlerConfiguration{ 283 { 284 DynamicBackend: &handler.DynamicBackendConfiguration{ 285 Name: "m3msg", 286 HashType: sharding.Murmur32Hash, 287 Producer: producerconfig.ProducerConfiguration{ 288 Writer: producerconfig.WriterConfiguration{ 289 TopicName: "aggregated_metrics", 290 MessagePool: &pool.ObjectPoolConfiguration{ 291 Size: 16384, 292 Watermark: pool.WatermarkConfiguration{ 293 RefillLowWatermark: 0.2, 294 RefillHighWatermark: 0.5, 295 }, 296 }, 297 }, 298 }, 299 }, 300 }, 301 }, 302 }, 303 Passthrough: &passthroughConfiguration{Enabled: true}, 304 Forwarding: forwardingConfiguration{MaxConstDelay: 1 * time.Minute}, 305 EntryTTL: 1 * time.Hour, 306 EntryCheckInterval: 10 * time.Minute, 307 MaxTimerBatchSizePerWrite: 140, 308 MaxNumCachedSourceSets: &defaultNumCachedSourceSets, 309 DiscardNaNAggregatedValues: &defaultDiscardNanValues, 310 EntryPool: pool.ObjectPoolConfiguration{Size: 4096}, 311 CounterElemPool: pool.ObjectPoolConfiguration{Size: 4096}, 312 TimerElemPool: pool.ObjectPoolConfiguration{Size: 4096}, 313 GaugeElemPool: pool.ObjectPoolConfiguration{Size: 4096}, 314 } 315 )