Skip to content

Commit

Permalink
fix(config)!: Make naming of InfluxDB tags consistent across entire c…
Browse files Browse the repository at this point in the history
…onfig file

Fixes #890
  • Loading branch information
Göran Sander committed Sep 11, 2024
1 parent 9c1bb5b commit 0ed25d5
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 58 deletions.
16 changes: 8 additions & 8 deletions src/config/production_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ Butler-SOS:
influxdb:
measurementName: event_count # Name of the InfluxDB measurement where event count is stored
tags: # Tags are added to the data before it's stored in InfluxDB
# - tag: env
# - name: env
# value: DEV
# - tag: foo
# - name: foo
# value: bar
rejectedEventCount:
enable: true # Should rejected events be counted and stored in InfluxDB?
Expand All @@ -111,9 +111,9 @@ Butler-SOS:
serverHost: <IP or FQDN> # Host/IP where user event server will listen for events from Sense
portUserActivityEvents: 9997 # Port on which user event server will listen for events from Sense
tags: # Tags are added to the data before it's stored in InfluxDB
# - tag: env
# - name: env
# value: DEV
# - tag: foo
# - name: foo
# value: bar
sendToMQTT:
enable: false # Set to true if user events should be forwarded as MQTT messages
Expand Down Expand Up @@ -148,9 +148,9 @@ Butler-SOS:
serverHost: <IP or FQDN> # Host/IP where log event server will listen for events from Sense
portLogEvents: 9996 # Port on which log event server will listen for events from Sense
tags:
# - tag: env
# - name: env
# value: DEV
# - tag: foo
# - name: foo
# value: bar
source:
engine:
Expand Down Expand Up @@ -233,9 +233,9 @@ Butler-SOS:
trackRejectedEvents:
enable: false # Should events that are rejected by the app performance monitor be tracked?
tags: # Tags are added to the data before it's stored in InfluxDB
# - tag: env
# - name: env
# value: DEV
# - tag: foo
# - name: foo
# value: bar
monitorFilter: # What objects should be monitored? Entire apps or just specific object(s) within some specific app(s)?
# Two kinds of monitoring can be done:
Expand Down
2 changes: 1 addition & 1 deletion src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class Settings {
)}`
);

tagValuesLogEvent.push(entry.tag);
tagValuesLogEvent.push(entry.name);
});
}

Expand Down
8 changes: 4 additions & 4 deletions src/lib/config-file-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const confifgFileSchema = {
measurementName: 'string',
'tags?': [
{
tag: 'string',
name: 'string',
value: 'string',
},
],
Expand Down Expand Up @@ -105,7 +105,7 @@ export const confifgFileSchema = {
},
'tags?': [
{
tag: 'string',
name: 'string',
value: 'string',
},
],
Expand Down Expand Up @@ -150,7 +150,7 @@ export const confifgFileSchema = {
},
'tags?': [
{
tag: 'string',
name: 'string',
value: 'string',
},
],
Expand Down Expand Up @@ -208,7 +208,7 @@ export const confifgFileSchema = {
enable: 'boolean',
'tags?': [
{
tag: 'string',
name: 'string',
value: 'string',
},
],
Expand Down
4 changes: 0 additions & 4 deletions src/lib/config-file-verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ export async function verifyConfigFile() {
const serverTagsDefinition = globals.config.get(
'Butler-SOS.serversToMonitor.serverTagsDefinition'
);
// eslint-disable-next-line no-restricted-syntax
for (const tag of serverTagsDefinition) {
// Check that all servers have this tag
const servers = globals.config.get('Butler-SOS.serversToMonitor.servers');
// eslint-disable-next-line no-restricted-syntax
for (const server of servers) {
// Check if server.serverTags.tag is defined
if (server?.serverTags === null || !server?.serverTags[tag]) {
Expand All @@ -90,9 +88,7 @@ export async function verifyConfigFile() {

// Now ensure that the tags defined for each server are valid and that there are no extra tags there
const servers = globals.config.get('Butler-SOS.serversToMonitor.servers');
// eslint-disable-next-line no-restricted-syntax
for (const server of servers) {
// eslint-disable-next-line no-restricted-syntax
for (const tag in server.serverTags) {
if (!serverTagsDefinition.includes(tag)) {
globals.logger.error(
Expand Down
20 changes: 10 additions & 10 deletions src/lib/post-to-influxdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ export async function postUserEventToInfluxdb(msg) {
) {
const configTags = globals.config.get('Butler-SOS.userEvents.tags');
for (const item of configTags) {
tags[item.tag] = item.value;
tags[item.name] = item.value;
}
}

Expand Down Expand Up @@ -824,7 +824,7 @@ export async function postUserEventToInfluxdb(msg) {
) {
const configTags = globals.config.get('Butler-SOS.userEvents.tags');
for (const item of configTags) {
point.tag(item.tag, item.value);
point.tag(item.name, item.value);
}
}

Expand Down Expand Up @@ -1043,7 +1043,7 @@ export async function postLogEventToInfluxdb(msg) {
) {
const configTags = globals.config.get('Butler-SOS.logEvents.tags');
for (const item of configTags) {
tags[item.tag] = item.value;
tags[item.name] = item.value;
}
}

Expand Down Expand Up @@ -1280,7 +1280,7 @@ export async function postLogEventToInfluxdb(msg) {
) {
const configTags = globals.config.get('Butler-SOS.logEvents.tags');
for (const item of configTags) {
point.tag(item.tag, item.value);
point.tag(item.name, item.value);
}
}

Expand Down Expand Up @@ -1357,7 +1357,7 @@ export async function storeEventCountInfluxDB() {
'Butler-SOS.qlikSenseEvents.eventCount.influxdb.tags'
);
for (const item of configTags) {
point.tags[item.tag] = item.value;
point.tags[item.name] = item.value;
}
}

Expand Down Expand Up @@ -1391,7 +1391,7 @@ export async function storeEventCountInfluxDB() {
'Butler-SOS.qlikSenseEvents.eventCount.influxdb.tags'
);
for (const item of configTags) {
point.tags[item.tag] = item.value;
point.tags[item.name] = item.value;
}
}

Expand Down Expand Up @@ -1468,7 +1468,7 @@ export async function storeEventCountInfluxDB() {
'Butler-SOS.qlikSenseEvents.eventCount.influxdb.tags'
);
for (const item of configTags) {
point.tag(item.tag, item.value);
point.tag(item.name, item.value);
}
}

Expand Down Expand Up @@ -1497,7 +1497,7 @@ export async function storeEventCountInfluxDB() {
'Butler-SOS.qlikSenseEvents.eventCount.influxdb.tags'
);
for (const item of configTags) {
point.tag(item.tag, item.value);
point.tag(item.name, item.value);
}
}

Expand Down Expand Up @@ -1578,7 +1578,7 @@ export async function storeRejectedEventCountInfluxDB() {
'Butler-SOS.logEvents.enginePerformanceMonitor.trackRejectedEvents.tags'
);
for (const item of configTags) {
tags[item.tag] = item.value;
tags[item.name] = item.value;
}
}

Expand Down Expand Up @@ -1699,7 +1699,7 @@ export async function storeRejectedEventCountInfluxDB() {
'Butler-SOS.logEvents.enginePerformanceMonitor.trackRejectedEvents.tags'
);
for (const item of configTags) {
point.tag(item.tag, item.value);
point.tag(item.name, item.value);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/post-to-mqtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function postUserEventToMQTT(msg) {
const configTags = globals.config.get('Butler-SOS.userEvents.tags');
// eslint-disable-next-line no-restricted-syntax
for (const item of configTags) {
payload.tags[item.tag] = item.value;
payload.tags[item.name] = item.value;
}
}

Expand Down Expand Up @@ -221,7 +221,7 @@ export function postLogEventToMQTT(msg) {
const configTags = globals.config.get('Butler-SOS.logEvents.tags');
// eslint-disable-next-line no-restricted-syntax
for (const item of configTags) {
payload.tags[item.tag] = item.value;
payload.tags[item.name] = item.value;
}
}

Expand Down
Loading

0 comments on commit 0ed25d5

Please sign in to comment.