Skip to content

DataDog FiveM wrapper to interact with the DataDog API

License

Notifications You must be signed in to change notification settings

pablo-1610/datadog_fivem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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


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" } })

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


Requiered:

  • metric_name

Usage:

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

Example: WIP


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