generated from nhcarrigan/template
feat: include date in metrics for aggregations
This commit is contained in:
+14
-4
@@ -87,18 +87,27 @@ export const instantiateServer = async(): Promise<void> => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { application, name, value, metadata } = request.body;
|
const { application, name, value, metadata } = request.body;
|
||||||
await fetch(`https://telemetry.nhcarrigan.com/api/33kzMoHcYaaEyqCFsauKPhTvEtx/ingest/metrics/_json`, {
|
await fetch(
|
||||||
body: JSON.stringify([ {
|
`https://telemetry.nhcarrigan.com/api/33kzMoHcYaaEyqCFsauKPhTvEtx/ingest/metrics/_json`,
|
||||||
|
{
|
||||||
|
body: JSON.stringify([
|
||||||
|
{
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- Needs to match API's structure.
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- Needs to match API's structure.
|
||||||
__name__: "metrics",
|
__name__: "metrics",
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- Needs to match API's structure.
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- Needs to match API's structure.
|
||||||
__type__: "count",
|
__type__: "count",
|
||||||
app: application,
|
app: application,
|
||||||
|
date: new Date().toLocaleDateString("en-GB", {
|
||||||
|
day: "numeric",
|
||||||
|
month: "long",
|
||||||
|
year: "numeric",
|
||||||
|
}),
|
||||||
metadata: metadata ?? {},
|
metadata: metadata ?? {},
|
||||||
name: name,
|
name: name,
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
value: value,
|
value: value,
|
||||||
} ]),
|
},
|
||||||
|
]),
|
||||||
headers: {
|
headers: {
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header.
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- Standard header.
|
||||||
"Authorization": `Basic ${process.env.TELEMETRY_TOKEN ?? ""}`,
|
"Authorization": `Basic ${process.env.TELEMETRY_TOKEN ?? ""}`,
|
||||||
@@ -106,7 +115,8 @@ export const instantiateServer = async(): Promise<void> => {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
method: "POST",
|
method: "POST",
|
||||||
});
|
},
|
||||||
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await errorHandler(error, "Metric Webhook");
|
await errorHandler(error, "Metric Webhook");
|
||||||
await response.status(500).send({ success: false });
|
await response.status(500).send({ success: false });
|
||||||
|
|||||||
Reference in New Issue
Block a user