Skip to content

Commit

Permalink
fix(influxdb): Storing proxy session data in InfluxDB v1 works again
Browse files Browse the repository at this point in the history
Fixes #816
  • Loading branch information
Göran Sander committed Jun 4, 2024
1 parent a30c34b commit 45312d7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
22 changes: 21 additions & 1 deletion src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ const tagValuesLogEventLogDb = tagValues.slice();
tagValuesLogEventLogDb.push('source_process');
tagValuesLogEventLogDb.push('log_level');

// Create tags for user sessions
const tagValuesUserProxySessions = tagValues.slice();
tagValuesUserProxySessions.push('user_session_virtual_proxy');
tagValuesUserProxySessions.push('user_session_host');

// Show Influxdb config
if (config.get('Butler-SOS.influxdbConfig.enable') === true) {
logger.info(`CONFIG: Influxdb enabled: true`);
Expand Down Expand Up @@ -358,7 +363,7 @@ if (config.get('Butler-SOS.influxdbConfig.enable') === true) {

// Set up Influxdb client
let influx;
let influxWriteApi = [];
const influxWriteApi = [];
if (config.get('Butler-SOS.influxdbConfig.enable') === true) {
if (config.get('Butler-SOS.influxdbConfig.version') === 1) {
// Set up Influxdb v1 client
Expand Down Expand Up @@ -483,6 +488,21 @@ if (config.get('Butler-SOS.influxdbConfig.enable') === true) {
},
tags: ['butler_sos_instance', 'version'],
},
{
measurement: 'user_session_summary',
fields: {
session_count: Influx.FieldType.INTEGER,
session_user_id_list: Influx.FieldType.STRING,
},
tags: tagValuesUserProxySessions,
},
{
measurement: 'user_session_list',
fields: {
session_user_id_list: Influx.FieldType.STRING,
},
tags: tagValuesUserProxySessions,
},
// {
// measurement: 'user_events',
// fields: {
Expand Down
7 changes: 2 additions & 5 deletions src/lib/proxysessionmetrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ function prepUserSessionMetrics(serverName, host, virtualProxy, body, tags) {
// Build tags structure, adding tags for virtual proxy and host the session is associated with
// Start with common/shared set of tags, then add user session specific tags
userProxySessionsData.tags = { ...tags };
// Esnure the virtual proxy does not begin or end with a slash or backslash
userProxySessionsData.tags.user_session_virtual_proxy = virtualProxy.replace(
/^[/\\]+|[/\\]+$/g,
''
);

userProxySessionsData.tags.user_session_virtual_proxy = virtualProxy;
userProxySessionsData.tags.user_session_host = host;

// Build comma separated list of all user IDs connected via the current virtual proxy
Expand Down

0 comments on commit 45312d7

Please sign in to comment.