Skip to content

Instantly share code, notes, and snippets.

@ninapavlich
Created November 12, 2019 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninapavlich/c774d7cbb04cee2b8a0b2aa254d85895 to your computer and use it in GitHub Desktop.
Save ninapavlich/c774d7cbb04cee2b8a0b2aa254d85895 to your computer and use it in GitHub Desktop.
Check if datadog agent is running
const fetch = require('node-fetch');
const hotShots = require('hot-shots');
const ddAgentHost = process.env.DD_AGENT_HOST || 'localhost';
async function checkAgentStatus() {
let metricsUp = 'OK (no error returned)';
let apmUp = '';
const datadog = new hotShots.StatsD({
protocol: undefined,
host: ddAgentHost,
port: 8125,
errorHandler(error) {
metricsUp += `errorHandler: ${error}`;
},
});
await datadog.close(async (error) => {
metricsUp = await `Close error: ${error}`;
console.log(metricsUp);
});
await fetch(`http://${ddAgentHost}:8126/services`)
.then(async (response) => {
console.log(await response.text());
apmUp = response.statusText;
})
.catch((error) => {
apmUp = error;
});
return {
metricsUp,
apmUp,
};
}
module.exports = {
checkAgentStatus,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment