# irrigate-datadog

Datadog recipe.


## MySQL

For mysql reporting, there are several options and configuration details:

### Metrics

For enhanced metrics, make sure the mysql user specified in your data bag (the name of which provided as the `node['datadog']['mysql_credentials_data_bag_name']` attribute) has the following access:
      * GRANT REPLICATION CLIENT ON *.*
      * GRANT PROCESS ON *.*
      * GRANT SELECT ON performance_schema.*

Sample specifying a data bag name
```json
"datadog": {
  "mysql_credentials_data_bag_name": "prod_datadog_mysql_credentials"
}
```

### Logs

Specify log files to be collected by the agent by providing an array of hashes, which would like this in a role (json):

```json
"datadog": {
  "logs": [
    {
      "type": "file",
      "path": "/var/log/service_name.log",
      "source": "service_name",
      "sourcecategory": "error",
      "service": "qa-service-name",
      "tags": [
        "service_name:service-name",
        "environment:qa"
      ]
    },
    {
      "type": "file",
      "path": "/var/log/custom-service.log",
      "source": "python",
      "sourcecategory": "application",
      "service": "prod-custom-service",
      "tags": [
        "service_name:custom-service",
        "location:passive"
      ]
    }
  ]
}
```


#### For Neo4j you can configure maximum size of single log message in bytes.

Specify max_message_size_bytes - integer - optional - The maximum size of single log message in bytes.
If maxMessageSizeBytes exceeds the documented API limit of 1MB - any payloads larger than 1MB will be dropped by the intake. Refer [docs.](https://docs.datadoghq.com/api/latest/logs/)


```json
"datadog": {
  "max_message_size_bytes": 256000
}
```


#### MySQL

Specify mysql-specific log files to be collected by the agent by specifying an array of hashes, which would like this in a role (json):

```json
"datadog": {
  "mysql": {
    "logs": [
      {
        "type": "file",
        "path": "/var/log/mysqld.log",
        "source": "mysql",
        "sourcecategory": "database",
        "service": "mysql"
      },
      {
        "type": "file",
        "path": "/var/log/mysql_slow_query.log",
        "source": "mysql",
        "sourcecategory": "database",
        "service": "mysql"
      }
    ]
  },
  "tags": {
    "service_name": "mysql"
  }
}
```

Each log should specify a type (file), path to file, source (for mapping in datadog), sourcecategory, and service (name of service).

### Custom queries

You can also provide custom queries that will be transformed into metrics by specifying an array of hashes, which would like this in a role (json):

```json
"datadog": {
  "mysql": {
    "queries": [
      {
        "type": "gauge",
        "field": "users_count",
        "metric": "mysql.users.count",
        "query": "SELECT COUNT(*) AS users_count FROM mysql.user"
      }
    ]
  }
}
```

Each query should specify a type (gauge, query, etc), field (the column to use for data values), metric (what you want to name the metric), and query (the query to be run, which should use the `AS` keyword to alias the column to the value you specified in `field`).

## Notes

The json snippets specified above would all typically be combined into a functional role.
