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
Credits
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