Skip to content

Instantly share code, notes, and snippets.

@alextanhongpin
Last active August 16, 2017 07:08
Show Gist options
  • Save alextanhongpin/cf44469d9a85a21814de7ed908fba927 to your computer and use it in GitHub Desktop.
Save alextanhongpin/cf44469d9a85a21814de7ed908fba927 to your computer and use it in GitHub Desktop.
Sample netstat.conf

In order to scrape golang data, it needs to be enabled in the python.conf.d:

// python.conf.d
go_expvar: yes

You also need to import expvar in the golang file

// main.go
import (
	_ "expvar"
  // ...
)
version: '3'
services:
mysql_source:
image: mysql
container_name: source
volumes:
- ./data/mysql_source:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=123456
- MYSQL_DATABASE=jobs
ports:
- 3306:3306
mysql_sink:
image: mysql
container_name: sink
volumes:
- ./data/mysql_sink:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=123456
- MYSQL_DATABASE=jobs
ports:
- 3307:3306
netdata:
image: titpetric/netdata
volumes:
- /sys:/host/sys:ro
- /proc:/host/proc:ro
- ./data/netdata/mysql.conf:/etc/netdata/python.d/mysql.conf
- ./data/netdata/go_expvar.conf:/etc/netdata/python.d/go_expvar.conf
# To enable golang profile, it must be turned on
- ./data/netdata/python.d.conf://etc/netdata/python.d.conf
environment:
- "--cap-add=SYS_PTRACE"
ports:
- 19999:19999
# netdata python.d.plugin configuration for go_expvar
#
# This file is in YaML format. Generally the format is:
#
# name: value
#
# There are 2 sections:
# - global variables
# - one or more JOBS
#
# JOBS allow you to collect values from multiple sources.
# Each source will have its own set of charts.
#
# JOB parameters have to be indented (using spaces only, example below).
# ----------------------------------------------------------------------
# Global Variables
# These variables set the defaults for all JOBs, however each JOB
# may define its own, overriding the defaults.
# update_every sets the default data collection frequency.
# If unset, the python.d.plugin default is used.
# update_every: 1
# priority controls the order of charts at the netdata dashboard.
# Lower numbers move the charts towards the top of the page.
# If unset, the default for python.d.plugin is used.
# priority: 60000
# retries sets the number of retries to be made in case of failures.
# If unset, the default for python.d.plugin is used.
# Attempts to restore the service are made once every update_every
# and only if the module has collected values in the past.
# retries: 5
# ----------------------------------------------------------------------
# JOBS (data collection sources)
#
# Any number of jobs is supported.
#
# All python.d.plugin JOBS (for all its modules) support a set of
# predefined parameters. These are:
#
# job_name:
# name: my_name # the JOB's name as it will appear at the
# # dashboard. If name: is not supplied the
# # job_name: will be used (use _ for spaces)
# # JOBs sharing a name are mutually exclusive
# update_every: 1 # the JOB's data collection frequency
# priority: 60000 # the JOB's order on the dashboard
# retries: 5 # the JOB's number of restoration attempts
#
# Additionally to the above, this plugin also supports the following:
#
# url: 'http://127.0.0.1/debug/vars' # the URL of the expvar endpoint
# ss_cert: # ignore HTTPS self-signed certificate
# proxy: # use HTTP proxy
#
# As the plugin cannot possibly know the port your application listens on, there is no default value. Please include
# the whole path of the endpoint, as the expvar handler can be installed in a non-standard location.
#
# if the URL is password protected, the following are supported:
#
# user: 'username'
# pass: 'password'
#
# collect_memstats: true # enables charts for Go runtime's memory statistics
# extra_charts: {} # defines extra data/charts to monitor, please see the example below
#
# If collect_memstats is disabled and no extra charts are defined, this module will disable itself, as it has no data to
# collect.
#
# Please visit the module wiki page for more information on how to use the extra_charts variable:
#
# https://github.com/firehol/netdata/wiki/Monitoring-Go-Applications#monitoring-custom-vars-with-go_expvar
#
# Configuration example
# ---------------------
go_app:
name : 'go_app'
url : 'http://docker.for.mac.localhost:5000/debug/vars'
collect_memstats: true
# extra_charts:
# - id: "runtime_goroutines"
# options:
# name: num_goroutines
# title: "runtime: number of goroutines"
# units: goroutines
# family: runtime
# context: expvar.runtime.goroutines
# chart_type: line
# lines:
# - {expvar_key: 'runtime.goroutines', expvar_type: int, id: runtime_goroutines}
# - id: "foo_counters"
# options:
# name: counters
# title: "some random counters"
# units: awesomeness
# family: counters
# context: expvar.foo.counters
# chart_type: line
# lines:
# - {expvar_key: 'counters.cnt1', expvar_type: int, id: counters_cnt1}
# - {expvar_key: 'counters.cnt2', expvar_type: float, id: counters_cnt2}
# netdata python.d.plugin configuration for mysql
#
# This file is in YaML format. Generally the format is:
#
# name: value
#
# There are 2 sections:
# - global variables
# - one or more JOBS
#
# JOBS allow you to collect values from multiple sources.
# Each source will have its own set of charts.
#
# JOB parameters have to be indented (using spaces only, example below).
# ----------------------------------------------------------------------
# Global Variables
# These variables set the defaults for all JOBs, however each JOB
# may define its own, overriding the defaults.
# update_every sets the default data collection frequency.
# If unset, the python.d.plugin default is used.
# update_every: 1
# priority controls the order of charts at the netdata dashboard.
# Lower numbers move the charts towards the top of the page.
# If unset, the default for python.d.plugin is used.
# priority: 60000
# retries sets the number of retries to be made in case of failures.
# If unset, the default for python.d.plugin is used.
# Attempts to restore the service are made once every update_every
# and only if the module has collected values in the past.
# retries: 5
# ----------------------------------------------------------------------
# JOBS (data collection sources)
#
# The default JOBS share the same *name*. JOBS with the same name
# are mutually exclusive. Only one of them will be allowed running at
# any time. This allows autodetection to try several alternatives and
# pick the one that works.
#
# Any number of jobs is supported.
#
# All python.d.plugin JOBS (for all its modules) support a set of
# predefined parameters. These are:
#
# job_name:
# name: myname # the JOB's name as it will appear at the
# # dashboard (by default is the job_name)
# # JOBs sharing a name are mutually exclusive
# update_every: 1 # the JOB's data collection frequency
# priority: 60000 # the JOB's order on the dashboard
# retries: 5 # the JOB's number of restoration attempts
#
# Additionally to the above, mysql also supports the following:
#
# socket: 'path/to/mysql.sock'
#
# or
# host: 'IP or HOSTNAME' # the host to connect to
# port: PORT # the port to connect to
#
# in all cases, the following can also be set:
#
# user: 'username' # the mysql username to use
# pass: 'password' # the mysql password to use
#
# ----------------------------------------------------------------------
# mySQL CONFIGURATION
#
# netdata does not need any privilege - only the ability to connect
# to the mysql server (netdata will not be able to see any data).
#
# Execute these commands to give the local user 'netdata' the ability
# to connect to the mysql server on localhost, without a password:
#
# > create user 'netdata'@'localhost';
# > grant usage on *.* to 'netdata'@'localhost' with grant option;
# > flush privileges;
#
# with the above statements, netdata will be able to gather mysql
# statistics, without the ability to see or alter any data or affect
# mysql operation in any way. No change is required below.
# ----------------------------------------------------------------------
# AUTO-DETECTION JOBS
# only one of them will run (they have the same name)
mycnf1:
name : 'local'
'my.cnf' : '/etc/my.cnf'
mycnf2:
name : 'local'
'my.cnf' : '/etc/mysql/my.cnf'
debiancnf:
name : 'local'
'my.cnf' : '/etc/mysql/debian.cnf'
socket1:
name : 'local'
# user : ''
# pass : ''
socket : '/var/run/mysqld/mysqld.sock'
socket2:
name : 'local'
# user : ''
# pass : ''
socket : '/var/run/mysqld/mysql.sock'
socket3:
name : 'local'
# user : ''
# pass : ''
socket : '/var/lib/mysql/mysql.sock'
socket4:
name : 'local'
# user : ''
# pass : ''
socket : '/tmp/mysql.sock'
tcp:
name : 'local'
# user : ''
# pass : ''
host : 'localhost'
port : '3306'
# keep in mind port might be ignored by mysql, if host = 'localhost'
# http://serverfault.com/questions/337818/how-to-force-mysql-to-connect-by-tcp-instead-of-a-unix-socket/337844#337844
tcpipv4:
name : 'local'
# user : ''
# pass : ''
host : '127.0.0.1'
port : '3306'
tcpipv6:
name : 'local'
# user : ''
# pass : ''
host : '::1'
port : '3306'
# Now we try the same as above with user: root
# A few systems configure mysql to accept passwordless
# root access.
mycnf1_root:
name : 'local'
user : 'root'
'my.cnf' : '/etc/my.cnf'
mycnf2_root:
name : 'local'
user : 'root'
'my.cnf' : '/etc/mysql/my.cnf'
socket1_root:
name : 'local'
user : 'root'
# pass : ''
socket : '/var/run/mysqld/mysqld.sock'
socket2_root:
name : 'local'
user : 'root'
# pass : ''
socket : '/var/run/mysqld/mysql.sock'
socket3_root:
name : 'local'
user : 'root'
# pass : ''
socket : '/var/lib/mysql/mysql.sock'
socket4_root:
name : 'local'
user : 'root'
# pass : ''
socket : '/tmp/mysql.sock'
tcp_root:
name : 'local'
user : 'root'
# pass : ''
host : 'localhost'
port : '3306'
# keep in mind port might be ignored by mysql, if host = 'localhost'
# http://serverfault.com/questions/337818/how-to-force-mysql-to-connect-by-tcp-instead-of-a-unix-socket/337844#337844
tcpipv4_root:
name : 'local'
user : 'root'
# pass : ''
host : '127.0.0.1'
port : '3306'
tcpipv6_root:
name : 'local'
user : 'root'
# pass : ''
host : '::1'
port : '3306'
# Now we try the same as above with user: netdata
mycnf1_netdata:
name : 'local'
user : 'netdata'
'my.cnf' : '/etc/my.cnf'
mycnf2_netdata:
name : 'local'
user : 'netdata'
'my.cnf' : '/etc/mysql/my.cnf'
socket1_netdata:
name : 'local'
user : 'netdata'
# pass : ''
socket : '/var/run/mysqld/mysqld.sock'
socket2_netdata:
name : 'local'
user : 'netdata'
# pass : ''
socket : '/var/run/mysqld/mysql.sock'
socket3_netdata:
name : 'local'
user : 'netdata'
# pass : ''
socket : '/var/lib/mysql/mysql.sock'
socket4_netdata:
name : 'local'
user : 'netdata'
# pass : ''
socket : '/tmp/mysql.sock'
tcp_netdata:
name : 'local'
user : 'netdata'
# pass : ''
host : 'localhost'
port : '3306'
# keep in mind port might be ignored by mysql, if host = 'localhost'
# http://serverfault.com/questions/337818/how-to-force-mysql-to-connect-by-tcp-instead-of-a-unix-socket/337844#337844
tcpipv4_netdata:
name : 'local'
user : 'netdata'
# pass : ''
host : '127.0.0.1'
port : '3306'
tcpipv6_netdata:
name : 'local'
user : 'netdata'
# pass : ''
host : '::1'
port : '3306'
# Important, monitor mysql
mysql_source_docker:
name : 'source'
user : 'root'
pass : '123456'
host : '::1'
port : '3306'
mysql_sink_docker:
name : 'sink'
user : 'root'
pass : '123456'
host : '::1'
port : '3307'
# netdata python.d.plugin configuration
#
# This file is in YaML format.
# Generally the format is:
#
# name: value
#
# Enable / disable the whole python.d.plugin (all its modules)
enabled: yes
# Prevent log flood
# Define how many log messages can be written to log file in one log_interval
logs_per_interval: 200
# Define how long is one logging interval (in seconds)
log_interval: 3600
# ----------------------------------------------------------------------
# Enable / Disable python.d.plugin modules
#default_run: yes
#
# If "default_run" = "yes" the default for all modules is enabled (yes).
# Setting any of these to "no" will disable it.
#
# If "default_run" = "no" the default for all modules is disabled (no).
# Setting any of these to "yes" will enable it.
# apache_cache has been replaced by web_log
apache_cache: no
# apache: yes
# bind_rndc: yes
# cpufreq: yes
# cpuidle: yes
# dns_query_time: yes
# dovecot: yes
# elasticsearch: yes
# this is just an example
example: no
# exim: yes
# fail2ban: yes
# freeradius: yes
# gunicorn_log has been replaced by web_log
gunicorn_log: no
go_expvar: yes
# haproxy: yes
# hddtemp: yes
# ipfs: yes
# isc_dhcpd: yes
# mdstat: yes
# memcached: yes
# mysql: yes
# nginx: yes
# nsd: yes
# nginx_log has been replaced by web_log
nginx_log: no
# ovpn_status_log: yes
# phpfpm: yes
# postfix: yes
# postgres: yes
# rabbitmq: yes
# redis: yes
# retroshare: yes
# sensors: yes
# samba: yes
# smartd_log: yes
# squid: yes
# tomcat: yes
# varnish: yes
# web_log: yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment