datadog_fivem icon indicating copy to clipboard operation
datadog_fivem copied to clipboard

DataDog FiveM wrapper to interact with the DataDog API

GitHub pull requests GitHub issues Twitter Follow GitHub Repo stars

DataDog FiveM Library (DDFL)

DDFL allows your FiveM server to interact with the DataDog REST API through HTTP requests. This can be useful if you want to monitor your server, measure its growth or simply collect statistics.

Summary

  1. Credits
  2. Installation
  3. Usage
  4. Queries
  5. To-do

Credits

DDFL by Pablo Z. (Discord)

How to install

To install this library, you just need to download it (or clone it) and then add ensure datadog-fivem to your server.cfg.

If you want, you can define your API key directly using the convar datadog_api_key.

🌐 To obtain or generate an API key, follow this link

Otherwise, use the ddfl:setApiKey event by passing your API key as a parameter to the event.

Usage: TriggerEvent("ddfl:setApiKey", "yourApiKeyHere")

Usage

To use DDFL, you must make sure that DDFL is started before any other script that will use it.

🌐 To obtain or generate an application key, follow this link

To make queries, you must authenticate with an application key. Create your authorization with this line;

TriggerEvent("ddfl:setApplication", "myApplicationName", "myApplicationKey")

TriggerEvent("ddf:setApplication", "myApplicationName", "myApplicationKey", true) (With logs)

You can put whatever you want for myApplicationName, it only serves to identify your application.

Queries

Here are the current possible queries


Submit metric(s)

Requiered:

  • metricTable

Usage:

TriggerEvent("ddfl:submitMetric", "myApplication", function(success)
    -- Code
end, metricTable)

Example:

TriggerEvent("ddfl:submitMetric", "myApplication", function(success)
    if (success) then
        print("Metric submitted")
    else
        print("Metric failed to submit")
    end
end, { metric = "test.metric", type = "gauge", points = { { os.time(), 1.5 } }, tags = { "user:me", "test:ok" } })

Get active metrics

Requiered:

  • from

Optional:

  • host
  • tag

Usage:

TriggerEvent("ddfl:getActiveMetrics", "myApplication", function(data)
    local metrics = data.metrics
    for k,v in pairs(metrics) do
      print("-> " .. v)
    end
end, from, host, tag)

Example: WIP


Get metric metadata

Requiered:

  • metric_name

Usage:

TriggerEvent("ddfl:getMetricMetadata", "myApplication", function(data)
    print(json.encode(data))
end, metric_name)

Example: WIP


(⭐) Get metric tag configuration

Warning: only accessible for Metrics without Limitsβ„’ users

Requiered:

  • metric_name

Usage:

TriggerEvent("ddfl:getMetricTagConfiguration", "myApplication", function(data)
    print(json.encode(data))
end, metric_name)

Example: WIP


TODO List

Done

βœ… β€’ Submit Metrics (usage)
βœ… β€’ Get active metrics (usage)
βœ… β€’ Get metric metadata (usage)
βœ… β€’ Get metric tag configuration (usage)

To do

βŒ› β€’ Create a tag configuration
βŒ› β€’ Edit metric metadata
βŒ› β€’ Edit tag configuration
βŒ› β€’ Delete tag configuration
βŒ› β€’ Search metrics
βŒ› β€’ List tag configuration
βŒ› β€’ Get timeseries points
βŒ› β€’ List tags by metric name
βŒ› β€’ List distinct metric volume by metric name