DataDog FiveM Library (DDFL)
- Statistics, monitoring and more !
- Standalone
- Open source
- Free to use
- Easy to use
Summary:
Description
DataDog-FiveM is a library to communicate with the REST API of the DataDog service (https://www.datadoghq.com/).
For those who don’t know, it is a service that allows to make statistical curves from sent data. DataDog also allows you to do monitoring.
Credits
Idea & Code by Pablo “PABLO-1610”
Code review by Jordan “AbsoluteDev”
Download
You can download the project from the repo by clicking here: datadog-fivem
This project is open source, which means that I invite all developers who wish to contribute and maintain this library to do so!
Installation
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")
Setup
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("ddfl:setApplication", "myApplicationName", "myApplicationKey", true)
(With logs)
You can put whatever you want for myApplicationName
, it only serves to identify your application.
Usage
Examples
Creating a simple graph with a single point
Code:
-- Set the API key
TriggerEvent("ddfl:setApiKey", "<yourApiKeyHere>")
-- Create an application instance with a name (just for you) and the app token
TriggerEvent("ddfl:setApplication", "myMonitoringApp", "<yourAppKeyHere>", true)
RegisterCommand("test_metric", function()
local currentTime, playersCount = os.time(), 25
TriggerEvent("ddfl:submitMetric", "myMonitoringApp", function(success)
if (success) then
print("Players count submitted")
else
print("Players count not submitted")
end
end, { metric = "myserver.players", type = "gauge", points = { { currentTime, 25 } }, tags = { "filter:all" } })
end)
Result:
Creating multiple points, with one delayed
Code:
-- (...) before this, set API key and app
RegisterCommand("test_metric_multiple", function()
local currentTime, playersCount = os.time(), 25
TriggerEvent("ddfl:submitMetric", "myMonitoringApp", function(success)
if (success) then
print("2 Players count submitted, with one in the past :o")
else
print("2 Players count not submitted")
end
end, { metric = "myserver.players.newPlayers", type = "gauge", points = { { currentTime, 10 }, { currentTime - (60*5), 5 } }, tags = { "filter:all" } })
end)
Results: