Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial configuration files for 3 main applications and exporters build script #6

Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e212c8f
Initial configuration files for 3 main applications
Nicolas-MacBeth Jul 22, 2020
d963099
Merge branch 'master' of github.com:GoogleCloudPlatform/opentelemetry…
Nicolas-MacBeth Jul 29, 2020
8caa5bd
build script and config updates
Nicolas-MacBeth Jul 30, 2020
ce1defd
commented out prefix
Nicolas-MacBeth Jul 30, 2020
6fa0cbf
updated config
Nicolas-MacBeth Jul 31, 2020
ea6c3a5
updated .gitignore
Nicolas-MacBeth Aug 5, 2020
cc966a1
reverted default file
Nicolas-MacBeth Aug 7, 2020
4806970
make and scripts updates, config file is not final
Nicolas-MacBeth Aug 12, 2020
cebf37f
Merge branch 'master' of github.com:GoogleCloudPlatform/opentelemetry…
Nicolas-MacBeth Aug 12, 2020
256563f
Merge branch 'master' of github.com:GoogleCloudPlatform/opentelemetry…
Nicolas-MacBeth Aug 13, 2020
5a602ff
statsD support
JingboWangGoogle Aug 14, 2020
e510add
Merge branch 'third-party-monitoring' of https://github.com/Nicolas-M…
JingboWangGoogle Aug 14, 2020
8e6f2a1
config now has three 3rd party apps, host metrics and diff pipeplines
Nicolas-MacBeth Aug 14, 2020
4fbba88
Merge branch 'third-party-monitoring' of github.com:Nicolas-MacBeth/o…
Nicolas-MacBeth Aug 14, 2020
e1cc1cf
Added statsd exporter build and config
Nicolas-MacBeth Aug 14, 2020
320be8e
readme docs for thrid party supports
JingboWangGoogle Aug 14, 2020
416e9d8
config and readme updates
Nicolas-MacBeth Aug 14, 2020
9e57e24
updated makefile with default config and updated config
Nicolas-MacBeth Aug 15, 2020
8dfe947
changed imports
Nicolas-MacBeth Aug 15, 2020
e4006b3
updated readme
Nicolas-MacBeth Aug 15, 2020
2339b74
go.mod updates
Nicolas-MacBeth Aug 18, 2020
940e3c2
config update
Nicolas-MacBeth Aug 18, 2020
a3675ef
0.9.0 upgrade
Nicolas-MacBeth Aug 29, 2020
29942cf
Merge branch 'master' of https://github.com/GoogleCloudPlatform/opent…
Nicolas-MacBeth Aug 29, 2020
67639b3
Merge branch 'master' of https://github.com/GoogleCloudPlatform/opent…
Nicolas-MacBeth Sep 7, 2020
8a1c0dc
go.mod update
Nicolas-MacBeth Sep 7, 2020
24098b0
Update README.md
Nicolas-MacBeth Sep 8, 2020
1ba403c
linting
Nicolas-MacBeth Sep 8, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .build/tar/build_exporters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# The use of >/dev/null is to supress stdout, but allow stderr to come thorugh
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved
# This is because installing the tools and building makes a lot of output
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved

echo "Installing tools needed"

# Install git and maven for building the exporters
sudo apt-get update >/dev/null
sudo apt-get install -y git >/dev/null
sudo apt-get install -y maven >/dev/null
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved

# check dist folder
if [ ! -d "dist" ]
then
echo "Not found: dist folder, creating the folder dist"
mkdir dist
fi

# Check for prometheus_exporters folder
if [ ! -d "dist/prometheus_exporters" ]
then
echo "Not found: prometheus_exporters folder, creating the folder"
mkdir dist/prometheus_exporters
fi
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved

echo "Building Prometheus exporters"

# Clone mysqld exporter, build the binary and put it in the folder
echo "Cloning and building the MySQL exporter"

git clone https://github.com/prometheus/mysqld_exporter.git -q
cd mysqld_exporter
make >/dev/null
cd ..
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved
cp mysqld_exporter/mysqld_exporter dist/prometheus_exporters/mysqld_exporter
rm -rf mysqld_exporter

# Clone Apache exporter, build the binary and put it in the folder
echo "Cloning and building the Apache exporter"

git clone https://github.com/Lusitaniae/apache_exporter.git -q
cd apache_exporter
make >/dev/null
cd ..
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved
cp apache_exporter/apache_exporter dist/prometheus_exporters/apache_exporter
rm -rf apache_exporter

# Clone JVM exporter, build the binary and put it in the folder
echo "Cloning and building the JVM exporter"

git clone https://github.com/prometheus/jmx_exporter.git -q
cd jmx_exporter
version=$(sed -n -e 's#.*<version>\(.*-SNAPSHOT\)</version>#\1#p' pom.xml)
mvn package >/dev/null
cd ..
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved
cp jmx_exporter/jmx_prometheus_httpserver/target/jmx_prometheus_httpserver-${version}-jar-with-dependencies.jar dist/prometheus_exporters/jmx_exporter.jar
rm -rf jmx_exporter

echo "Prometheus exporters built"
14 changes: 6 additions & 8 deletions .build/tar/generate_tar.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash

CONFIG_FILE=${CONFIG_FILE:-config-example.yaml}
EXPORTERS_DIRECTORY=prometheus_exporters
EXPORTERS_CONFIG_DIRECTORY=exporter_configs

echo "Start building tarball distribution file"

Expand All @@ -11,22 +13,18 @@ then
exit 1
fi

# check dist folder
if [ ! -d "dist" ]
then
echo "Not found: dist folder, creating the folder dist"
mkdir dist
fi
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved

# move the needed files into dist folder
echo "Organizing files to be compressed"
cp config/$CONFIG_FILE dist/
cp bin/$OTELCOL_BINARY dist/
cp -r config/$EXPORTERS_CONFIG_DIRECTORY dist/

# compress the binary and the config into a .tar file
echo "Compressing..."
cd dist && tar -cvzf google-cloudops-opentelemetry-collector.tar.gz $OTELCOL_BINARY $CONFIG_FILE
cd dist && tar -cvzf google-cloudops-opentelemetry-collector.tar.gz $OTELCOL_BINARY $CONFIG_FILE $EXPORTERS_DIRECTORY $EXPORTERS_CONFIG_DIRECTORY

# remove the folders and files that were added
echo "Cleaning up"
rm $OTELCOL_BINARY $CONFIG_FILE
rm -rf $EXPORTERS_DIRECTORY
rm -rf $EXPORTERS_CONFIG_DIRECTORY
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ ifeq ($(BUILD_IMAGE_NAME),)
BUILD_IMAGE_NAME=otelopscol-build
endif

OTELCOL_BINARY=google-cloudops-opentelemetry-collector

OTELCOL_BINARY=google-cloudops-opentelemetry-collector_$(GOOS)_$(GOARCH)$(EXTENSION)
james-bebbington marked this conversation as resolved.
Show resolved Hide resolved
.EXPORT_ALL_VARIABLES:

# --------------------------
Expand All @@ -38,7 +37,7 @@ OTELCOL_BINARY=google-cloudops-opentelemetry-collector

.PHONY: build
build:
go build -o ./bin/$(OTELCOL_BINARY)_$(GOOS)_$(GOARCH)$(EXTENSION) ./cmd/otelopscol
go build -o ./bin/$(OTELCOL_BINARY) ./cmd/otelopscol

# googet (Windows)

Expand All @@ -57,14 +56,19 @@ package-goo:
goopack -output_dir ./dist <(envsubst < ./.build/googet/google-cloudops-opentelemetry-collector.goospec)
chmod -R 777 ./dist/

# exporters
.PHONY: build-exporters
build-exporters:
bash ./.build/tar/build_exporters.sh

# tarball

.PHONY: build-tarball
build-tarball: build package-tarball
build-tarball: build build-exporters package-tarball
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: package-tarball
package-tarball:
./.build/tar/generate_tar.sh
bash ./.build/tar/generate_tar.sh
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved
chmod -R 777 ./dist/

# --------------------
Expand Down
5 changes: 4 additions & 1 deletion cmd/otelopscol/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package main

import (
"github.com/Nicolas-MacBeth/opentelemetry-collector-contrib/receiver/prometheusexecreceiver" //update when merged
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/stackdriverexporter"
"github.com/open-telemetry/opentelemetry-collector-contrib/processor/metricstransformprocessor"
"go.opentelemetry.io/collector/component"
Expand All @@ -39,7 +40,9 @@ func components() (config.Factories, error) {
errs = append(errs, err)
}

receivers := []component.ReceiverFactoryBase{}
receivers := []component.ReceiverFactoryBase{
&prometheusexecreceiver.Factory{},
}
for _, rcv := range factories.Receivers {
receivers = append(receivers, rcv)
}
Expand Down
83 changes: 83 additions & 0 deletions config/config-mysql_apache_jvm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# This config hopes to mimick the Cloud Monitoring Agent by collecting metrics from popular third-party services the Agent already supports
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved
# and formatting the metrics in the same way, so they appear similarly in Cloud Monitoring. The services targeted here are MySQL, Apache and JVM.
# Please remove/comment-out the prometheus_exec configs that you don't need in the receivers section as well as the list in the service/pipelines/metrics/receivers section.
# Documentation specific to each exporter is found in the comment directly above its configuration

receivers:

# https://github.com/prometheus/mysqld_exporter
prometheus_exec/mysql:
exec: ./prometheus_exporters/mysqld_exporter --web.listen-address=":{{port}}" --no-collect.global_variables # this last flag reduces the amount of generated metrics, can be removed to enable all (600+) MySQL metrics
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved
port: 9104
env:
- name: DATA_SOURCE_NAME # DATA_SOURCE_NAME and its value are needed to connect to the MySQL server, alternatively you could use a .my.cnf configuration file
value: username:password@(host:port)/db_name # replace all value here with your MySQL server credentials

# https://github.com/Lusitaniae/apache_exporter
prometheus_exec/apache:
exec: ./prometheus_exporters/apache_exporter --telemetry.address=":{{port}}"
port: 9117

# https://github.com/prometheus/jmx_exporter
prometheus_exec/jvm:
exec: java -jar ./prometheus_exporters/jmx_exporter.jar {{port}} exporter_configs/jvm_config.yaml # see jvm_config.yaml for JMX configuration, notably the "hostPort" key
port: 9404

processors:
filter:
metrics:
include:
match_type: regexp
metric_names: # Allowing all JVM and Apache metrics, but whitelisting MySQL ones to filter hundreds of unused ones
- mysql_global_status_commands_total
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved
- mysql_global_status_threads_running
- mysql_global_status_handlers_total
- apache_.*
- jmx_.*
- java_.*
- promhttp_.*
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved

metricstransform/mysql:
transforms:
- metric_name: mysql_global_status_commands_total
action: update
new_name: mysql/command_count
operations:
# change data type from double -> int64
- action: toggle_scalar_data_type
- metric_name: mysql_global_status_threads_running
action: update
new_name: mysql/thread_count
- metric_name: mysql_global_status_handlers_total
action: update
new_name: mysql/handler_count

metricstransform/java:
transforms:
- metric_name: java_lang_GarbageCollector_CollectionCount
action: update
new_name: jvm/gc/count

metricstransform/apache:
transforms:
- metric_name: promhttp_metric_handler_requests_total
action: update
new_name: apache/request_count
operations:
- action: aggregate_labels
label_set: []
aggregation_type: sum
# change data type from double -> int64
- action: toggle_scalar_data_type

exporters:
stackdriver:
project: # stackdriver will use the default GCE credentials
#metric_prefix: agent.googleapis.com/

service:
pipelines:
metrics:
receivers: [prometheus_exec/mysql, prometheus_exec/apache, prometheus_exec/jvm] # Remember to remove unwanted receivers from this list
processors: [filter, metricstransform/mysql, metricstransform/java]
Nicolas-MacBeth marked this conversation as resolved.
Show resolved Hide resolved
exporters: [stackdriver]
6 changes: 6 additions & 0 deletions config/exporter_configs/jvm_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Simple JMX exporter config file, please change host:port of your particular JVM configuration
# Documentation: https://github.com/prometheus/jmx_exporter

jmxUrl: service:jmx:rmi:///jndi/rmi://host:port/jmxrmi
startDelaySeconds: 0
ssl: false
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/GoogleCloudPlatform/opentelemetry-operations-collector
go 1.14

require (
github.com/Nicolas-MacBeth/opentelemetry-collector-contrib/receiver/prometheusexecreceiver v0.0.0-20200730172100-e63745f3601e // update when merged
github.com/StackExchange/wmi v0.0.0-20181212234831-e0a55b97c705 // indirect
github.com/go-ole/go-ole v1.2.4 // indirect
github.com/hashicorp/consul/api v1.4.0 // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF0
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
github.com/Nicolas-MacBeth/opentelemetry-collector-contrib/receiver/prometheusexecreceiver v0.0.0-20200730172100-e63745f3601e h1:yZLatx4UQSpOT4sZ4Ym3gO40OMedAieydLHw2vnUhSE=
github.com/Nicolas-MacBeth/opentelemetry-collector-contrib/receiver/prometheusexecreceiver v0.0.0-20200730172100-e63745f3601e/go.mod h1:LQUXv42nhnFoqOeZopxsWTjWATwd2uk41+3UojST9dU=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/OneOfOne/xxhash v1.2.5 h1:zl/OfRA6nftbBK9qTohYBJ5xvw6C/oNKizR7cZGl3cI=
Expand Down Expand Up @@ -851,6 +853,7 @@ github.com/karrick/godirwalk v1.7.7/go.mod h1:2c9FRhkDxdIbgkOnCEvnSWs71Bhugbl46s
github.com/karrick/godirwalk v1.7.8/go.mod h1:2c9FRhkDxdIbgkOnCEvnSWs71Bhugbl46shStcFDJ34=
github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4=
github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
Expand Down