Skip to content

Commit b3cb730

Browse files
vjkoskelaBrandonArp
authored andcommitted
Migration histogram to use fastutil's primitive sorted map. (#85)
* Migration histogram to use fastutil's primitive sorted map.
1 parent 0048e95 commit b3cb730

File tree

8 files changed

+371
-49
lines changed

8 files changed

+371
-49
lines changed

README.md

Lines changed: 135 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,19 @@ In the installation's *bin* directory there are scripts to start Metrics Aggrega
3939

4040
#### Logging
4141

42-
To customize logging you may provide a [LogBack](http://logback.qos.ch/) configuration file. To use a custom logging configuration you need to define and export an environment variable before executing *mad*:
42+
To customize logging you may provide a [LogBack](http://logback.qos.ch/) configuration file. The project ships with `logback.xml` which
43+
writes logs to rotated files and with `logback-console.xml` which writes logs to STDOUT.
4344

44-
export JAVA_OPTS="-Dlogback.configurationFile=/usr/local/lib/metrics-aggregator-daemon/config/logger.xml"
45+
Outside of Docker, set the `JAVA_OPTS` environment variable to configure logging:
46+
47+
export JAVA_OPTS="-Dlogback.configurationFile=/usr/local/lib/metrics-aggregator-daemon/config/logback-console.xml"
4548

4649
Where */usr/local/lib/metrics-aggregator-daemon/config/logger.xml* is the path to your logging configuration file.
4750

51+
Under Docker, set the `LOGBACK_CONFIG` environment variable to configure logging:
52+
53+
docker run -e LOGBACK_CONFIG=/opt/mad/config/logack-console.xml arpnetworking/mad:latest
54+
4855
#### Daemon
4956

5057
The Metrics Aggregator Daemon configuration is specified in a JSON file. The location of the configuration file is passed to *mad* as a command line argument:
@@ -139,38 +146,156 @@ Each of the pipeline configuration files should be placed in the *pipelinesDirec
139146

140147
The daemon and pipeline configuration files may be written in [Hocon](https://github.com/typesafehub/config) when specified with a _.conf extension.
141148

149+
### Sources
150+
151+
#### Collectd
152+
153+
Example MAD source configuration:
154+
```json
155+
{
156+
type="com.arpnetworking.metrics.mad.sources.MappingSource"
157+
name="collectd_mapping_source"
158+
"findAndReplace": {
159+
"^cpu/([\\d]+)/(cpu|percent)/([^/]+)(/value)?": ["cpu/$3", "cpu/by_core/$1/$3"],
160+
"^snmp/cpu_detailed/([\\d]+)/([^/]+)(/value)?": ["snmp/cpu/$2", "snmp/cpu/by_core/$1/$2"],
161+
"^load/load/((1|5|15)min)": ["load/$1"],
162+
"^memory/memory/([^/]+)(/value)?": ["memory/$1"],
163+
"^vmem/vmpage_number/([^/]+)(/value)?": ["vmem/$1"],
164+
"^vmem/vmpage_io/([^/]+)/(.*)": ["vmem/io/$1/$2"],
165+
"^vmem/vmpage_faults/(.*)": ["vmem/faults/$1"],
166+
"^swap/swap/([^/]+)(/value)?": ["swap/$1"],
167+
"^swap/swap_io/([^/]+)(/value)?": ["swap/io/$1"],
168+
"^interface/([^/]+)/if_([^/]+)/(.*)": ["interface/$1/$3/$2"],
169+
"^disk/([^/]+)/disk_([^/]+)/(read|write)": ["disk/$1/$3/$2"],
170+
"^df/(.*)(/value)?": ["disk/$1"],
171+
"^ntpd/(.*)(/value)?": ["ntpd/$1"],
172+
"^processes/ps_state/([^/]+)(/value)?": ["processes/by_state/$1"],
173+
"^processes/([^/]+)/ps_(vm|rss|data|code|stacksize)(/value)?": ["processes/by_name/$1/$2"],
174+
"^processes/([^/]+)/ps_(cputime|count|pagefaults)/(.*)": ["processes/by_name/$1/$2/$3"],
175+
"^processes/([^/]+)/ps_disk_([^/]+)/(.*)": ["processes/by_name/$1/disk/$3/$2"],
176+
"^tcpconns/([^-]+)-(local|remote)/tcp_connections/([^/]+)(/value)?": ["tcpconns/$2/$1/$3"],
177+
"^tcpconns/all/tcp_connections/([^/]+)(/value)?": ["tcpconns/all/$1"],
178+
"^memcached/df/cache/(.*)": ["memcached/cache/$1"],
179+
"^memcached/memcached_command/([^/]+)(/value)?": ["memcached/commands/$1"],
180+
"^memcached/memcached_connections/current(/value)?": ["memcached/connections"],
181+
"^memcached/memcached_items/current(/value)?": ["memcached/items"],
182+
"^memcached/memcached_octets/rx": ["memcached/network/bytes_read"],
183+
"^memcached/memcached_octets/tx": ["memcached/network/bytes_written"],
184+
"^memcached/memcached_ops/([^/]+)(/value)?": ["memcached/operations/$1"],
185+
"^memcached/percent/([^/]+)(/value)?": ["memcached/$1"],
186+
"^memcached/ps_count/.*": [],
187+
"^memcached/ps_cputime/.*": [],
188+
"^uptime/uptime(/value)?": ["uptime/value"]
189+
},
190+
"source": {
191+
type="com.arpnetworking.metrics.common.sources.CollectdHttpSourceV1"
192+
actorName="collectd-http-source"
193+
name="collectd_http_source"
194+
}
195+
}
196+
```
197+
198+
Example Collectd write plugin configuration:
199+
```
200+
LoadPlugin write_http
201+
<Plugin "write_http">
202+
<Node "mad">
203+
URL "http://localhost:7090/metrics/v1/collectd"
204+
Format "JSON"
205+
Header "X-TAG-SERVICE: collectd"
206+
Header "X-TAG-CLUSTER: collectd_local"
207+
StoreRates true
208+
BufferSize 4096
209+
</Node>
210+
</Plugin>
211+
```
212+
213+
#### Telegraf
214+
215+
Example MAD source configuration:
216+
```json
217+
{
218+
type="com.arpnetworking.metrics.mad.sources.MappingSource"
219+
name="telegraftcp_mapping_source"
220+
findAndReplace={
221+
"\\."=["/"]
222+
}
223+
source={
224+
type="com.arpnetworking.metrics.common.sources.TcpLineSource"
225+
actorName="telegraf-tcp-source"
226+
name="telegraftcp_source"
227+
host="0.0.0.0"
228+
port="8094"
229+
parser={
230+
type="com.arpnetworking.metrics.mad.parsers.TelegrafJsonToRecordParser"
231+
timestampUnit="NANOSECONDS"
232+
}
233+
}
234+
}
235+
```
236+
237+
Example Telegraf output configuration:
238+
```
239+
[agent]
240+
interval="1s"
241+
flush_interval="1s"
242+
round_interval=true
243+
omit_hostname=false
244+
245+
[global_tags]
246+
service="telegraf"
247+
cluster="telegraf_local"
248+
249+
[[outputs.socket_writer]]
250+
address = "tcp://localhost:8094"
251+
data_format = "json"
252+
json_timestamp_units = "1ns"
253+
keep_alive_period = "5m"
254+
255+
[[inputs.cpu]]
256+
percpu = true
257+
totalcpu = true
258+
collect_cpu_time = false
259+
report_active = false
260+
[[inputs.mem]]
261+
[[inputs.net]]
262+
[[inputs.netstat]]
263+
[[inputs.disk]]
264+
interval="10s"
265+
[[inputs.diskio]]
266+
[[inputs.swap]]
267+
[[inputs.kernel]]
268+
```
269+
142270
Development
143271
-----------
144272

145273
To build the service locally you must satisfy these prerequisites:
146-
* [JDK8](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
147274
* [Docker](http://www.docker.com/) (for [Mac](https://docs.docker.com/docker-for-mac/))
148275

149276
__Note:__ Requires at least Docker for Mac Beta version _Version 1.12.0-rc4-beta19 (build: 10258)_
150277

151-
You will need an account on [Docker Hub](https://hub.docker.com/) and need to provide these credentials in order for the build to pull the base image(s). Please refer to the [Fabric8 Maven Docker Plugin](https://dmp.fabric8.io/#authentication) for how to provide these credentials. To get started quickly you can pass them on the command line via _-Ddocker.pull.username_ and _-Ddocker.pull.password_.
152-
153278
Next, fork the repository, clone and build:
154279

155280
Building:
156281

157-
metrics-aggregator-daemon> ./mvnw verify
282+
metrics-aggregator-daemon> ./jdk-wrapper.sh ./mvnw verify
158283

159284
To debug the server during run on port 9000:
160285

161-
metrics-aggregator-daemon> ./mvnw -Ddebug=true docker:start
286+
metrics-aggregator-daemon> ./jdk-wrapper.sh ./mvnw -Ddebug=true docker:start
162287

163288
To debug the server during integration tests on port 9000:
164289

165-
metrics-aggregator-daemon> ./mvnw -Ddebug=true verify
290+
metrics-aggregator-daemon> ./jdk-wrapper.sh ./mvnw -Ddebug=true verify
166291

167292
To execute performance tests:
168293

169-
metrics-aggregator-daemon> ./mvnw -PperformanceTest test
294+
metrics-aggregator-daemon> ./jdk-wrapper.sh ./mvnw -PperformanceTest test
170295

171296
To use the local version in your project you must first install it locally:
172297

173-
metrics-aggregator-daemon> ./mvnw install
298+
metrics-aggregator-daemon> ./jdk-wrapper.sh ./mvnw install
174299

175300
You can determine the version of the local build from the pom.xml file. Using the local version is intended only for testing or development.
176301

config/config.conf

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
monitoringCluster="mad"
2-
logDirectory="logs"
1+
# Pipelines
2+
# ~~~~
33
pipelinesDirectory="config/pipelines"
4+
5+
# Http Server
6+
# ~~~~
47
httpHost="0.0.0.0"
58
httpPort=7090
6-
httpHealthCheckPath="/ping"
7-
httpStatusPath="/status"
8-
jvmMetricsCollectionInterval="PT.5S"
9+
#httpHealthCheckPath="/ping"
10+
#httpStatusPath="/status"
11+
#supplementalHttpRoutesClass="com.example.MyAkkaRoutes"
12+
13+
# Metrics
14+
# ~~~~
15+
monitoringCluster="mad"
16+
#jvmMetricsCollectionInterval="PT.5S"
17+
18+
# Logging
19+
# ~~~~
20+
logDirectory="logs"
21+
22+
# Akka
23+
# ~~~~
924
akkaConfiguration {
1025
akka {
1126
loggers = [ "akka.event.slf4j.Slf4jLogger" ]

config/logback-console.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2018 Inscope Metrics, Inc.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<configuration>
18+
<appender name="mad-logger" class="ch.qos.logback.core.ConsoleAppender">
19+
<encoder class="com.arpnetworking.logback.StenoEncoder">
20+
<injectContextLogger>true</injectContextLogger>
21+
<compressLoggerName>true</compressLoggerName>
22+
<jacksonModule class="com.fasterxml.jackson.datatype.joda.JodaModule" />
23+
<jacksonModule class="com.fasterxml.jackson.datatype.guava.GuavaModule" />
24+
<jacksonModule class="com.fasterxml.jackson.datatype.jdk8.Jdk8Module" />
25+
<injectBeanIdentifier>true</injectBeanIdentifier>
26+
</encoder>
27+
</appender>
28+
29+
<logger name="org.reflections.Reflections" level="ERROR" />
30+
31+
<root level="INFO">
32+
<appender-ref ref="mad-logger"/>
33+
</root>
34+
</configuration>

config/logback.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
~ See the License for the specific language governing permissions and
1515
~ limitations under the License.
1616
-->
17-
<configuration>
17+
<configuration scan="true" scanPeriod="30 seconds">
1818
<appender name="mad-logger" class="ch.qos.logback.core.rolling.RollingFileAppender">
1919
<file>/opt/mad/logs/mad.log</file>
2020
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
@@ -36,7 +36,6 @@
3636
</encoder>
3737
</appender>
3838

39-
4039
<appender name="mad-async" class="ch.qos.logback.classic.AsyncAppender">
4140
<appender-ref ref="mad-logger"/>
4241
<discardingThreshold>50</discardingThreshold>

0 commit comments

Comments
 (0)