Monitoring Vault with Datadog
Challenge
Monitoring is a critical part of administration of any software system. Proactively collecting, visualizing, and analyzing data on Vault is no different, as insight into the details of how Vault instance(s) are important to decision making, quality assurance and troubleshooting.
Solution
In order to get aggregated data about the instance(s) of Vault, you can use Datadog. It is a mature monitoring solution that will report common resource metrics like CPU, memory and network metrics out of the box.
This tutorial covers set-up and configuration of Datadog Agent to monitor an instance of Vault Enterprise. Then you will look over the metrics available, and finally clean up the Datadog Agent and the local Vault installation.
Prerequisites
To enable the Datadog Agent to gather metrics from Vault Enterprise, you will need to have:
- Free Tier Datadog account. Sign up for a free account at Datadog Pricing.
- A Vault Enterprise environment. Refer to the Vault install guide to install Vault.
- Mac Workstation with MacOS 10.12 or higher, though much of this will be the same for other platforms.
Set up the Datadog agent locally
You will need an API key from Datadog. From the Datadog dashboard, select your user name at the bottom of the left navigation.
Select Organizational Settings, and then API Keys which lists existing API keys.
Select an API key created for your username.
Copy the API Key value, and then store it as a
DATADOG_API_KEY
environment variable.Open a terminal and run the following command to install Datadog Agent.
Output:
Verify that the agent is running.
Example output:
If you encountered an error, try executing
datadog-agent stop
and thendatadog-agent run
again.
Set up the Vault integration
In order for Vault to send metrics, you need to set up access for the agent to connect to Datadog. For this tutorial, use unauthenticated access.
Open another terminal and start a Vault dev server with
root
as the root token.Navigate to
/opt/datadog-agent/etc/conf.d/vault.d
.In the
/vault.d
directory, make a copy ofconf.yaml.example
.Open the
conf.yaml
file with an editor of your choice. Find theinstances:
section, and notice that theapi_url
parameter points to the Vault address to pull metrics from which is set to the locally running Vault (http://localhost:8200/v1
).Locate the
no_token
parameter and set it totrue
for the convenience of this tutorial.conf.yamlRestart the Datadog Agent to apply the configuration changes.
Stop the Datadog Agent.
Run the agent again.
Monitor the Vault metrics
Now that the agent is installed and running, you need to validate that the agent is correctly sending data to Datadog. Metrics about both your workstation and your Vault Enterprise Instance should be streaming to Datadog.
In your Datadog dashboard, select Metrics > Explorer.
The Explorer page shows the default metrics of
system.cpu.user
.With Metrics selected, start typing in
vault.
and you will see a number of available Vault metrics.Explorer the available metrics collected by the Datadog.
Clean up
When you are done exploring, clean up both the Datadog Agent and the Vault environment.
Find your platform Uninstall the Agent for instructions on how to uninstall the agent for your platform of choice.
If you are running Vault locally in
dev
mode, stop the Vault dev server by pressing Ctrl+C where the server is running. Or, execute the following command.
References
- Details on Vault metrics available through Datadog: Metrics for Vault Cluster Heath and Leader Changes
- How to monitor HashiCorp Vault with Datadog
- Datadog Integrations
- Datadog Agent Troubleshooting
- Datadog Agent Commands
- Datadog Agent's Configuration Directory