<LoadPlugin mysql> | |||||
Globals false | |||||
</LoadPlugin> | |||||
<Plugin mysql> | |||||
<Database "mysql"> | |||||
Host "localhost" | |||||
Socket "{{ plugin.socket }}" | |||||
User "{{ plugin.username }}" | |||||
Password "{{ plugin.password }}" | |||||
MasterStats false | |||||
SlaveStats false | |||||
</Database> | |||||
</Plugin> |
Import "collectd_mysql_check" | |||||
<Module "collectd_mysql_check"> | |||||
Host "localhost" | |||||
Socket "{{ plugin.socket }}" | |||||
Username "{{ plugin.username }}" | |||||
Password "{{ plugin.password }}" | |||||
</Module> | |||||
<LoadPlugin dbi> | |||||
Globals false | |||||
</LoadPlugin> | |||||
<Plugin dbi> | |||||
<Query "wsrep_ready"> | |||||
Statement "select replace(lower(VARIABLE_NAME), 'wsrep_', 'cluster.') as metric, replace(replace(VARIABLE_VALUE, 'ON', 1), 'OFF', 0) as value from information_schema.GLOBAL_STATUS where VARIABLE_NAME IN ('wsrep_ready', 'wsrep_connected');" | |||||
MinVersion 50000 | |||||
<Result> | |||||
Type "gauge" | |||||
InstancesFrom "metric" | |||||
ValuesFrom "value" | |||||
</Result> | |||||
</Query> | |||||
<Query "wsrep_cluster_status"> | |||||
Statement "select replace(replace(lower(VARIABLE_NAME), 'wsrep_', ''), '_', '.') as metric, replace(replace(replace(VARIABLE_VALUE, 'Primary', 1), 'Non-Primary', 2), 'Disconnected', 3) as value from information_schema.GLOBAL_STATUS where VARIABLE_NAME = 'wsrep_cluster_status';" | |||||
MinVersion 50000 | |||||
<Result> | |||||
Type "gauge" | |||||
InstancesFrom "metric" | |||||
ValuesFrom "value" | |||||
</Result> | |||||
</Query> | |||||
<Query "wsrep_cluster"> | |||||
Statement "select replace(replace(lower(VARIABLE_NAME), 'wsrep_', 'cluster.'), 'cluster_size', 'size') as metric, VARIABLE_VALUE as value from information_schema.GLOBAL_STATUS where VARIABLE_NAME IN ('wsrep_cluster_size', 'wsrep_replicated', 'wsrep_replicated_bytes', 'wsrep_received_bytes', 'wsrep_received', 'wsrep_local_commits', 'wsrep_local_cert_failures', 'wsrep_local_send_queue', 'Slow_queries');" | |||||
MinVersion 50000 | |||||
<Result> | |||||
Type "gauge" | |||||
InstancesFrom "metric" | |||||
ValuesFrom "value" | |||||
</Result> | |||||
</Query> | |||||
<Database "mysql_status"> | |||||
Driver "mysql" | |||||
DriverOption "mysql_unix_socket" "{{ plugin.socket }}" | |||||
DriverOption "username" "{{ plugin.username }}" | |||||
DriverOption "password" "{{ plugin.password }}" | |||||
DriverOption "dbname" "mysql" | |||||
SelectDB "mysql" | |||||
Query "wsrep_ready" | |||||
Query "wsrep_cluster_status" | |||||
Query "wsrep_cluster" | |||||
</Database> | |||||
</Plugin> |
{%- set master = salt['grains.filter_by']({ | {%- set master = salt['grains.filter_by']({ | ||||
'Debian': { | 'Debian': { | ||||
'pkgs': ['mysql-server-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'libmysqlclient18', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat'], | |||||
'pkgs': ['mysql-server-wsrep-5.6', 'galera-3', 'rsync', 'python-mysqldb', 'libmysqlclient18', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'], | |||||
'service': 'mysql', | 'service': 'mysql', | ||||
'wsrep_provider': '/usr/lib/galera/libgalera_smm.so', | 'wsrep_provider': '/usr/lib/galera/libgalera_smm.so', | ||||
'log_file': '/var/log/mysql.log', | 'log_file': '/var/log/mysql.log', | ||||
{%- set slave = salt['grains.filter_by']({ | {%- set slave = salt['grains.filter_by']({ | ||||
'Debian': { | 'Debian': { | ||||
'pkgs': ['mysql-server-wsrep', 'galera', 'rsync', 'python-mysqldb', 'libmysqlclient18', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat'], | |||||
'pkgs': ['mysql-server-wsrep', 'galera', 'rsync', 'python-mysqldb', 'libmysqlclient18', 'psmisc', 'netcat', 'percona-xtrabackup', 'socat', 'libdbd-mysql', 'python-pymysql'], | |||||
'service': 'mysql', | 'service': 'mysql', | ||||
'wsrep_provider': '/usr/lib/galera/libgalera_smm.so', | 'wsrep_provider': '/usr/lib/galera/libgalera_smm.so', | ||||
'log_file': '/var/log/mysql.log', | 'log_file': '/var/log/mysql.log', |
{%- if pillar.galera is defined %} | |||||
{%- if pillar.galera.master is defined %} | |||||
{%- from "galera/map.jinja" import master with context %} | |||||
{%- set server = master %} | |||||
{%- elif pillar.galera.slave is defined %} | |||||
{%- from "galera/map.jinja" import slave with context %} | |||||
{%- set server = slave %} | |||||
{%- endif %} | |||||
{%- endif %} | |||||
{%- if server is defined %} | |||||
local_plugin: | |||||
mysql: | |||||
template: galera/files/collectd_mysql.conf | |||||
socket: {{ server.socket }} | |||||
password: {{ server.admin.password }} | |||||
username: {{ server.admin.user }} | |||||
mysql_status: | |||||
template: galera/files/collectd_mysql_status.conf | |||||
socket: {{ server.socket }} | |||||
password: {{ server.admin.password }} | |||||
username: {{ server.admin.user }} | |||||
mysql_check: | |||||
plugin: python | |||||
template: galera/files/collectd_mysql_check.conf | |||||
socket: {{ server.socket }} | |||||
password: {{ server.admin.password }} | |||||
username: {{ server.admin.user }} | |||||
{%- endif %} |
dashboard: | |||||
galera: | |||||
format: json | |||||
template: galera/files/grafana_dashboards/mysql_influxdb.json |
log_collector: | |||||
decoder: | |||||
galera: | |||||
engine: sandbox | |||||
module_file: /usr/share/lma_collector/decoders/galera.lua | |||||
module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules | |||||
adjust_timezone: true | |||||
input: | |||||
galera: | |||||
engine: logstreamer | |||||
log_directory: "/var/log" | |||||
file_match: 'mysql/error.log$' | |||||
differentiator: ["galera"] | |||||
decoder: "galera_decoder" | |||||
splitter: "galera_splitter" | |||||
splitter: | |||||
galera: | |||||
engine: regex | |||||
delimiter: '\n([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2})' | |||||
delimiter_eol: false | |||||
metric_collector: | |||||
trigger: | |||||
mysql_check: | |||||
description: 'MySQL cannot be checked' | |||||
severity: down | |||||
rules: | |||||
- metric: mysql_check | |||||
relational_operator: '==' | |||||
threshold: 0 | |||||
window: 60 | |||||
periods: 0 | |||||
function: last | |||||
mysql_node_connected: | |||||
description: 'The MySQL service has lost connectivity with the other nodes' | |||||
severity: critical | |||||
rules: | |||||
- metric: mysql_cluster_connected | |||||
relational_operator: '==' | |||||
threshold: 0 | |||||
window: 30 | |||||
periods: 1 | |||||
function: min | |||||
mysql_node_ready: | |||||
description: "The MySQL service isn't ready to serve queries" | |||||
severity: critical | |||||
rules: | |||||
- metric: mysql_cluster_ready | |||||
relational_operator: '==' | |||||
threshold: 0 | |||||
window: 30 | |||||
periods: 1 | |||||
function: min | |||||
alarm: | |||||
mysql_check: | |||||
alerting: enabled | |||||
triggers: | |||||
- mysql_check | |||||
dimension: | |||||
service: mysql | |||||
mysql_node_status: | |||||
alerting: enabled | |||||
triggers: | |||||
- mysql_node_connected | |||||
- mysql_node_ready | |||||
dimension: | |||||
service: mysql | |||||
aggregator: | |||||
alarm_cluster: | |||||
mysql: | |||||
policy: majority_of_members | |||||
alerting: enabled_with_notification | |||||
match: | |||||
service: mysql | |||||
group_by: hostname | |||||
members: | |||||
- mysql_check | |||||
- mysql_node_status | |||||
dimension: | |||||
cluster_name: mysql | |||||
nagios_host: 00-top-clusters |
applications: | applications: | ||||
- galera | - galera | ||||
classes: | |||||
- service.galera.support | |||||
parameters: | parameters: | ||||
_param: | _param: | ||||
galera_server_cluster_name: galeracluster | galera_server_cluster_name: galeracluster | ||||
- name: haproxy | - name: haproxy | ||||
host: '%' | host: '%' | ||||
- name: haproxy | - name: haproxy | ||||
host: ${_param:cluster_local_address} | |||||
host: ${_param:cluster_local_address} |
applications: | applications: | ||||
- galera | - galera | ||||
classes: | |||||
- service.galera.support | |||||
parameters: | parameters: | ||||
_param: | _param: | ||||
galera_server_cluster_name: galeracluster | galera_server_cluster_name: galeracluster | ||||
- name: haproxy | - name: haproxy | ||||
host: '%' | host: '%' | ||||
- name: haproxy | - name: haproxy | ||||
host: ${_param:cluster_local_address} | |||||
host: ${_param:cluster_local_address} |
galera: | galera: | ||||
_support: | _support: | ||||
collectd: | collectd: | ||||
enabled: false | |||||
enabled: true | |||||
heka: | heka: | ||||
enabled: false | |||||
enabled: true | |||||
sensu: | sensu: | ||||
enabled: true | enabled: true | ||||
sphinx: | sphinx: | ||||
enabled: true | enabled: true | ||||
config: | config: | ||||
enabled: true | |||||
enabled: true | |||||
grafana: | |||||
enabled: true |