Git Product home page Git Product logo

mikrotikjson4datadogapi's Introduction

MikrotikJSON4DatadogAPI

This is a simple example to generate and push metrics in JSON format to Datadog API using RouterOS scripting language.

I'm using Timeseries Points POST Datadog API call.

With this example you can generate a dashboard like that:

datadog-public-dashboard-example

So, let's go!

First step, LoadGlobalFunctions.rsc

At first, we need to add some basic global functions and load them on startup.

You have to go on System \ Scheduler and add a new Schedule.

Configure the schedule this way:

  • Schedule nameLoadAllFunctions
  • Start DateNov/27/2018
  • Start Timestartup
  • Interval00:00:00
  • On Eventjust copy/paste LoadGlobalFunctions.rsc content

Ok, now if we reboot our router we will get loaded three functions. We can find them on System \ Scripts \ Environment.

These loaded scripts are named:

  • functionJulianDate Julian Calendar function wich convert RouterOS date call in JD format seconds
  • timestamp Timestamp function to get UNIX POSIX timestamp in UTC timezone
  • uptimeseconds Get uptime in seconds

Second step, DatadogMonitoring.rsc

First of all we need to generate an API Key and a new Application Key. We can do it here.

Once created both keys, as already done before, we have to add a new Schedule. This one generate the JSON data and push it to Datadog API using fetch command. We need to adapt vars on the script because when we call Datadog API we need to identify ourself with the generated API key and Application key.

When you copy DatadogMonitoring.rsc pay attention to the first part of the script identified as "Datadog API Settings".

Adapt all the values:

  • apikeyYour API keys are unique to your organization. An API key is required by the Datadog Agent to submit metrics and events to Datadog.
  • applicationkeyApplication keys, in conjunction with your org's API key, give you full access to Datadog's programmatic API. Application keys are associated with the user account that created them and can be named. The application key is used to log all requests made to the API.
  • ddendpoint"https://app.datadoghq.com/api/v1" URL Datadog API endpoint.
  • type"gauge" [optional, default=gauge]: Type of your metric either: gauge, rate, or count.
  • tags"source:mikrotik" [optional, default=None]: A list of tags associated with the metric.

Now you have to go once again on System \ Scheduler and add a new Schedule.

Configure the schedule this way:

  • Schedule nameDatadogMonitoring
  • Start DateNov/27/2018
  • Start Time00:00:00
  • Interval00:00:05
  • On Eventcopy/paste the modified content of DatadogMonitoring.rsc

You can adjust Interval seconds value in order to change the frequency timeframe for generation and push of the JSON to Datadog.

Let's test!

You can see system.cpu.load metric using Metrics Explorer on Datadog website.

Click here for an example: https://app.datadoghq.com/metric/explorer?live=true&exp_metric=system.cpu.load

mikrotikjson4datadogapi's People

Contributors

mtrimarchi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.