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

New Integration ProxySQL #6144

Merged
merged 29 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
05040e4
Original ProxySQL implementation
reyiyo Mar 25, 2020
5132137
Use QueryManager
FlorianVeaux Mar 25, 2020
74a21f2
integration and e2e testing
FlorianVeaux Mar 26, 2020
30ba2cc
use configspecs
FlorianVeaux Mar 26, 2020
d697a8f
Fix tests
FlorianVeaux Mar 26, 2020
f556527
Update service_checks.json
FlorianVeaux Mar 26, 2020
3e288a2
Update metadata.csv
FlorianVeaux Mar 26, 2020
c908f50
Update documentation
FlorianVeaux Mar 26, 2020
458d68a
Cleanup comment
FlorianVeaux Mar 26, 2020
ddbc952
Submit version metadata
FlorianVeaux Mar 26, 2020
fc46312
Update licensing
FlorianVeaux Mar 26, 2020
7a644ad
Test more versions and assert version metadata submission
FlorianVeaux Mar 26, 2020
dab9b17
Fix metadata encoding
FlorianVeaux Mar 27, 2020
0fd2919
Update query_cache metrics to rate
FlorianVeaux Mar 27, 2020
f8061d7
Update public visibility in manifest.json
FlorianVeaux Mar 27, 2020
24131b6
Update proxysql/README.md
FlorianVeaux Mar 27, 2020
a06c345
Update proxysql/README.md
FlorianVeaux Mar 27, 2020
ceec4a0
Update proxysql/manifest.json
FlorianVeaux Mar 27, 2020
f2a294c
Update proxysql/manifest.json
FlorianVeaux Mar 27, 2020
f5be9d5
Update proxysql/README.md
FlorianVeaux Mar 27, 2020
47dc26a
Add SSL support
FlorianVeaux Mar 27, 2020
70d6600
Add '.' to metric descriptions
FlorianVeaux Mar 27, 2020
5518c59
Fix tests
FlorianVeaux Mar 27, 2020
70a9a86
Address review
FlorianVeaux Mar 31, 2020
7e8386c
Fix link in docs
FlorianVeaux Mar 31, 2020
41ddf95
Update proxysql/datadog_checks/proxysql/proxysql.py
FlorianVeaux Apr 1, 2020
c5c8605
Update proxysql/datadog_checks/proxysql/ssl_utils.py
FlorianVeaux Apr 1, 2020
10dd5cf
Update proxysql/tests/conftest.py
FlorianVeaux Apr 1, 2020
3123482
Address review
FlorianVeaux Apr 1, 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
3 changes: 3 additions & 0 deletions .azure-pipelines/templates/test-all-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ jobs:
- checkName: prometheus
displayName: Prometheus
os: linux
- checkName: proxysql
displayName: ProxySQL
os: linux
- checkName: rabbitmq
displayName: RabbitMQ
os: linux
Expand Down
2 changes: 2 additions & 0 deletions proxysql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# CHANGELOG - ProxySQL

10 changes: 10 additions & 0 deletions proxysql/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
graft datadog_checks
graft tests

include MANIFEST.in
include README.md
include requirements.in
include requirements-dev.txt
include manifest.json

global-exclude *.py[cod] __pycache__
112 changes: 112 additions & 0 deletions proxysql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Agent Check: ProxySQL

## Overview

This check monitors [ProxySQL][1] through the Datadog Agent.

## Setup

Follow the instructions below to install and configure this check for an Agent running on a host. For containerized environments, see the [Autodiscovery Integration Templates][2] for guidance on applying these instructions.

### Installation

The ProxySQL integration is included in the [Datadog Agent][3] package, so you don't need to install anything else on your servers.

### Configuration

#### Host

1. Edit the `proxysql.d/conf.yaml` file, in the `conf.d/` folder at the root of your [Agent's configuration directory][4] to start collecting your ProxySQL performance data. See the [sample proxysql.d/conf.yaml][5] for all available configuration options.

2. [Restart the Agent][6].

##### Log Collection

1. Collecting logs is disabled by default in the Datadog Agent, enable it in your `datadog.yaml` file:

```yaml
logs_enabled: true
```

2. Add the log files you are interested in to your `proxysql.d/conf.yaml` file to start collecting your ProxySQL logs:

```yaml
logs:
# Default logging file
- type: file
path: /var/log/proxysql.log
source: proxysql
service: "<SERVICE_NAME>"
# Logged queries, file needs to be in JSON
# https://github.com/sysown/proxysql/wiki/Query-Logging
- type: file
path: "<QUERY_LOGGING_FILE_PATH>"
source: proxysql
service: "<SERVICE_NAME>"
# Audit log
# https://github.com/sysown/proxysql/wiki/Audit-log
- type: file
path: "<AUDIT_LOG_FILE_PATH>"
source: proxysql
service: "<SERVICE_NAME>"
```

Change the `path` and `service` parameter values and configure them for your environment. See the [sample proxysql.d/conf.yaml][5] for all available configuration options.

3. [Restart the Agent][6].

#### Containerized

For containerized environments, see the [Autodiscovery Integration Templates][2] for guidance on applying the parameters below.

#### Metric Collection

| Parameter | Value |
|----------------------|------------------------------------------------------------|
| `<INTEGRATION_NAME>` | `proxysql` |
| `<INIT_CONFIG>` | blank or `{}` |
| `<INSTANCE_CONFIG>` | `{"host": "%%host%%", "port": "%%port%%", "username": "<USER>", "password": "<PASSWORD>"}` |

##### Log collection

Collecting logs is disabled by default in the Datadog Agent. To enable it, see [Docker log collection][9].

| Parameter | Value |
|----------------|-------------------------------------------|
| `<LOG_CONFIG>` | `{"source": "proxysql", "service": "<SERVICE_NAME>"}` |


### Validation

[Run the Agent's status subcommand][7] and look for `proxysql` under the Checks section.

## Data Collected

### Metrics

See [metadata.csv][8] for a list of metrics provided by this check.

### Service Checks

`proxysql.can_connect`: Returns `CRITICAL` if the Agent can't connect to ProxySQL, otherwise returns `OK`. This service check is tagged by `server` and `port`

`proxysql.backend.status`: Returns `CRITICAL` if ProxySQL considers the backend host as SHUNNED or OFFLINE_HARD. Returns `WARNING` if the backend host is `OFFLINE_SOFT`. Returns `OK` otherwise. This service check is tagged by `hostgroup`, `srv_host` and `srv_port`.

### Events

The ProxySQL check does not include any events.

## Troubleshooting

Need help? Contact [Datadog support][7].
FlorianVeaux marked this conversation as resolved.
Show resolved Hide resolved

[1]: https://proxysql.com/
[2]: https://docs.datadoghq.com/agent/autodiscovery/integrations
[3]: https://docs.datadoghq.com/agent
[4]: https://docs.datadoghq.com/agent/guide/agent-configuration-files/#agent-configuration-directory
[5]: https://github.com/DataDog/integrations-core/blob/master/proxysql/datadog_checks/proxysql/data/conf.yaml.example
[6]: https://docs.datadoghq.com/agent/guide/agent-commands/#start-stop-and-restart-the-agent
[7]: https://docs.datadoghq.com/agent/guide/agent-commands/#agent-status-and-information
[8]: https://github.com/DataDog/integrations-core/blob/master/proxysql/metadata.csv
[9]: https://docs.datadoghq.com/agent/docker/log
[10]: https://docs.datadoghq.com/help
82 changes: 82 additions & 0 deletions proxysql/assets/configuration/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: ProxySQL
files:
- name: proxysql.yaml
options:
- template: init_config
options:
- template: init_config/default
- template: instances
options:
- name: host
required: true
description: |
Specify the ProxySQL host to connect to.
value:
type: string
example: <PROXYSQL_HOST>
- name: port
required: true
description: |
The ProxySQL port to use for the Admin interface
value:
type: integer
- name: username
required: true
description: |
The ProxySQL admin user. It must be able to connect remotely.
value:
type: string
example: <PROXYSQL_ADMIN_USER>
- name: password
required: true
description: |
The ProxySQL admin password.
value:
type: string
example: <PROXYSQL_ADMIN_PASSWORD>
- name: tls_verify
value:
example: false
type: boolean
description: Instructs the check to use SSL when connecting to ProxySQL
- name: tls_ca_cert
value:
example: <CA_CERT_PATH>
type: string
description: |
The path to the `proxysql-ca.pem` file generated by ProxySQL when using SSL (or your own).
More information: https://github.com/sysown/proxysql/wiki/SSL-Support#ssl-configuration-for-frontends
- name: validate_hostname
value:
example: true
type: boolean
description: Whether or not to verify the certificate was issued for the given `host`
- name: connect_timeout
required: false
description: |
Timeout in seconds for connecting to ProxySQL.
value:
type: integer
example: 10
- name: read_timeout
required: false
description: |
Timeout in seconds for reading data from ProxySQL. Unlimited by default.
value:
type: integer
- name: additional_metrics
description: |
List of additional metrics to collect in addition to the global ones.
Learn more about thest metrics at:
https://github.com/sysown/proxysql/wiki/STATS-(statistics)
value:
type: array
items:
type: string
example:
- command_counters_metrics
- connection_pool_metrics
- users_metrics
- memory_metrics
- query_rules_metrics
- template: instances/default
20 changes: 20 additions & 0 deletions proxysql/assets/service_checks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"agent_version": "6.19.0",
"integration": "ProxySQL",
"check": "proxysql.can_connect",
"statuses": ["ok", "critical"],
"groups": ["server", "port"],
"name": "ProxySQL Can Connect",
"description": "Returns `CRITICAL` if the Agent can't connect to ProxySQL, otherwise returns `OK`."
},
{
"agent_version": "6.19.0",
"integration": "ProxySQL",
"check": "proxysql.backend.status",
"statuses": ["ok", "warning", "critical"],
"groups": ["hostgroup", "srv_host", "srv_port"],
"name": "Status of the MySQL backend servers from ProxySQL perspective.",
"description": "Returns `CRITICAL` if ProxySQL considers the backend host as SHUNNED or OFFLINE_HARD. Returns `WARNING` if the backend host is `OFFLINE_SOFT`. Returns `OK` otherwise."
}
]
4 changes: 4 additions & 0 deletions proxysql/datadog_checks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
4 changes: 4 additions & 0 deletions proxysql/datadog_checks/proxysql/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
__version__ = '0.0.1'
7 changes: 7 additions & 0 deletions proxysql/datadog_checks/proxysql/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# (C) Datadog, Inc. 2020-present
# All rights reserved
# Licensed under a 3-clause BSD style license (see LICENSE)
from .__about__ import __version__
from .proxysql import ProxysqlCheck

__all__ = ['__version__', 'ProxysqlCheck']
101 changes: 101 additions & 0 deletions proxysql/datadog_checks/proxysql/data/conf.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
## All options defined here are available to all instances.
#
init_config:

## @param service - string - optional
## Attach the tag `service:<SERVICE>` to every metric, event, and service check emitted by this integration.
##
## Additionally, this sets the default `service` for every log source.
#
# service: <SERVICE>

## Every instance is scheduled independent of the others.
#
instances:

## @param host - string - required
## Specify the ProxySQL host to connect to.
#
- host: <PROXYSQL_HOST>

## @param port - integer - required
## The ProxySQL port to use for the Admin interface
#
port: <PORT>

## @param username - string - required
## The ProxySQL admin user. It must be able to connect remotely.
#
username: <PROXYSQL_ADMIN_USER>

## @param password - string - required
## The ProxySQL admin password.
#
password: <PROXYSQL_ADMIN_PASSWORD>

## @param tls_verify - boolean - optional - default: false
## Instructs the check to use SSL when connecting to ProxySQL
#
# tls_verify: false

## @param tls_ca_cert - string - optional
## The path to the `proxysql-ca.pem` file generated by ProxySQL when using SSL (or your own).
## More information: https://github.com/sysown/proxysql/wiki/SSL-Support#ssl-configuration-for-frontends
#
# tls_ca_cert: <CA_CERT_PATH>

## @param validate_hostname - boolean - optional - default: true
## Whether or not to verify the certificate was issued for the given `host`
#
# validate_hostname: true

## @param connect_timeout - integer - optional - default: 10
## Timeout in seconds for connecting to ProxySQL.
#
# connect_timeout: 10

## @param read_timeout - integer - optional
## Timeout in seconds for reading data from ProxySQL. Unlimited by default.
#
# read_timeout: <READ_TIMEOUT>

## @param additional_metrics - list of strings - optional
## List of additional metrics to collect in addition to the global ones.
## Learn more about thest metrics at:
## https://github.com/sysown/proxysql/wiki/STATS-(statistics)
#
# additional_metrics:
# - command_counters_metrics
# - connection_pool_metrics
# - users_metrics
# - memory_metrics
# - query_rules_metrics

## @param tags - list of strings - optional
## A list of tags to attach to every metric and service check emitted by this instance.
##
## Learn more about tagging at https://docs.datadoghq.com/tagging
#
# tags:
# - <KEY_1>:<VALUE_1>
# - <KEY_2>:<VALUE_2>

## @param service - string - optional
## Attach the tag `service:<SERVICE>` to every metric, event, and service check emitted by this integration.
##
## Overrides any `service` defined in the `init_config` section.
#
# service: <SERVICE>

## @param min_collection_interval - number - optional - default: 15
## This changes the collection interval of the check. For more information, see:
## https://docs.datadoghq.com/developers/write_agent_check/#collection-interval
#
# min_collection_interval: 15

## @param empty_default_hostname - boolean - optional - default: false
## This forces the check to send metrics with no hostname.
##
## This is useful for cluster-level checks.
#
# empty_default_hostname: false
Loading