Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MS SQL Server Errorlog Support #1687

Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions apps/mssql.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,80 @@ import (
"context"

"github.com/GoogleCloudPlatform/ops-agent/confgenerator"
"github.com/GoogleCloudPlatform/ops-agent/confgenerator/fluentbit"
"github.com/GoogleCloudPlatform/ops-agent/confgenerator/otel"
"github.com/GoogleCloudPlatform/ops-agent/internal/platform"
)

type LoggingProcessorMssqlLog struct {
confgenerator.ConfigComponent `yaml:",inline"`
}

func (LoggingProcessorMssqlLog) Type() string {
return "mssql_errorlog"
}

func (p LoggingProcessorMssqlLog) Components(ctx context.Context, tag string, uid string) []fluentbit.Component {
c := confgenerator.LoggingProcessorParseRegex{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the Regex, we need the parser shared section that tells fluentbit how to parse the timestamp. the one below is copied from saphana so it's not the right field/format.

ParserShared: confgenerator.ParserShared{
			TimeKey:    "time",
			TimeFormat: "%Y-%m-%d %H:%M:%S.%L",
}
			

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original PR calls this out:

// Not sending the log timestamp "logtime" from above in as the Time_Key as there will be time zone issues.
// MS SQL Server writes logs in server time, not a standard time zone such as UTC

I can add these comments in

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll add the comment and see how the ops-agent team would like to handle it.

// SAMPLE LOG ENTRIES, including multiline:
//
// 2022-03-20 00:00:00.27 spid56 Microsoft SQL Server 2019 (RTM-CU4) (KB4548597) - 15.0.4033.1 (X64)
// Mar 14 2020 16:10:35
// Copyright (C) 2019 Microsoft Corporation
// Developer Edition (64-bit) on Windows Server 2019 Datacenter 10.0 <X64> (Build 17763: ) (Hypervisor)
//
// 2022-03-20 00:00:00.28 spid56 UTC adjustment: -5:00
// 2022-03-20 00:00:00.28 spid56 (c) Microsoft Corporation.
// 2022-03-20 00:00:00.28 spid56 All rights reserved.
// 2022-03-20 00:00:00.28 spid56 Server process ID is 3432.
// 2022-03-20 00:00:00.28 spid56 System Manufacturer: 'Google', System Model: 'Google Compute Engine'.
// 2022-03-20 00:00:00.28 spid56 Authentication mode is MIXED.
// 2022-03-20 00:00:01.90 Backup Log was backed up. Database: demo, creation date(time): 2020/01/31(10:33:17), first LSN: 582441:259880:1, last LSN: 582441:259912:1, number of dump devices: 1, device information: (FILE=1, TYPE=DISK: {'\\server\share\DatabaseBackups\demo.trn'}). This is an informational message only. No user action is required.
// 2022-03-20 00:00:03.76 Logon Error: 18456, Severity: 14, State: 38.
Regex: `^(?<timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{2}) (?<process>\w+)\s+(?<message>[\s|\S]*)?`,
// Not sending the log timestamp from above because MSSQL logs use server time
}.Components(ctx, tag, uid)

c = append(c, fluentbit.Component{
Kind: "FILTER",
Config: map[string]string{
"Name": "modify",
"Match": tag,
"Add": "logging.googleapis.com/severity info",
},
})
return c
}

type LoggingReceiverMssqlLog struct {
LoggingProcessorMssqlLog `yaml:",inline"`
confgenerator.LoggingReceiverFilesMixin `yaml:",inline" validate:"structonly"`
}

func (r LoggingReceiverMssqlLog) Components(ctx context.Context, tag string) []fluentbit.Component {
if len(r.IncludePaths) == 0 {
r.IncludePaths = []string{
"/var/opt/mssql/log/errorlog",
"C:\\Program Files\\Microsoft SQL Server\\MSSQL.*\\MSSQL\\LOG\\ERRORLOG",
}
}
r.MultilineRules = []confgenerator.MultilineRule{
{
StateName: "start_state",
NextState: "cont",
Regex: `\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{2}`,
},
{
StateName: "cont",
NextState: "cont",
Regex: `^(?!\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{2})`,
},
}
c := r.LoggingReceiverFilesMixin.Components(ctx, tag)
c = append(c, r.LoggingProcessorMssqlLog.Components(ctx, tag, r.Type())...)
return c
}

type MetricsReceiverMssql struct {
confgenerator.ConfigComponent `yaml:",inline"`

Expand Down Expand Up @@ -108,4 +178,6 @@ func (m MetricsReceiverMssql) Pipelines(_ context.Context) ([]otel.ReceiverPipel

func init() {
confgenerator.MetricsReceiverTypes.RegisterType(func() confgenerator.MetricsReceiver { return &MetricsReceiverMssql{} }, platform.Windows)
confgenerator.LoggingProcessorTypes.RegisterType(func() confgenerator.LoggingProcessor { return &LoggingProcessorMssqlLog{} })
confgenerator.LoggingReceiverTypes.RegisterType(func() confgenerator.LoggingReceiver { return &LoggingReceiverMssqlLog{} })
}
5 changes: 5 additions & 0 deletions confgenerator/testdata/feature/golden.csv
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ App,Field,Override,
*apps.LoggingProcessorIisAccess,confgenerator.ConfigComponent.Type,
*apps.LoggingProcessorJettyAccess,confgenerator.ConfigComponent.Type,
*apps.LoggingProcessorKafka,confgenerator.ConfigComponent.Type,
*apps.LoggingProcessorMssqlLog,confgenerator.ConfigComponent.Type,
*apps.LoggingProcessorMysqlError,confgenerator.ConfigComponent.Type,
*apps.LoggingProcessorMysqlGeneral,confgenerator.ConfigComponent.Type,
*apps.LoggingProcessorMysqlSlow,confgenerator.ConfigComponent.Type,
Expand Down Expand Up @@ -98,6 +99,10 @@ App,Field,Override,
*apps.LoggingReceiverMongodb,confgenerator.LoggingReceiverFilesMixin.BufferInMemory,
*apps.LoggingReceiverMongodb,confgenerator.LoggingReceiverFilesMixin.RecordLogFilePath,
*apps.LoggingReceiverMongodb,confgenerator.LoggingReceiverFilesMixin.WildcardRefreshInterval,
*apps.LoggingReceiverMssqlLog,apps.LoggingProcessorMssqlLog.confgenerator.ConfigComponent.Type,
*apps.LoggingReceiverMssqlLog,confgenerator.LoggingReceiverFilesMixin.BufferInMemory,
*apps.LoggingReceiverMssqlLog,confgenerator.LoggingReceiverFilesMixin.RecordLogFilePath,
*apps.LoggingReceiverMssqlLog,confgenerator.LoggingReceiverFilesMixin.WildcardRefreshInterval,
*apps.LoggingReceiverMysqlError,apps.LoggingProcessorMysqlError.confgenerator.ConfigComponent.Type,
*apps.LoggingReceiverMysqlError,confgenerator.LoggingReceiverFilesMixin.BufferInMemory,
*apps.LoggingReceiverMysqlError,confgenerator.LoggingReceiverFilesMixin.RecordLogFilePath,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mssql_errorlog, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mssql_errorlog, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mssql_errorlog, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mssql_errorlog, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mssql_errorlog, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mssql_errorlog, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mssql_errorlog, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mssql_errorlog, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mssql_errorlog, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
Original file line number Diff line number Diff line change
@@ -1 +1 @@
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
logging receiver with type "systemd_journald" is not supported. Supported logging receiver types: [active_directory_ds, apache_access, apache_error, cassandra_debug, cassandra_gc, cassandra_system, couchbase_general, couchbase_goxdcr, couchbase_http_access, couchdb, elasticsearch_gc, elasticsearch_json, files, flink, fluent_forward, hadoop, hbase_system, iis_access, jetty_access, kafka, mongodb, mssql_errorlog, mysql_error, mysql_general, mysql_slow, nginx_access, nginx_error, oracledb_alert, oracledb_audit, postgresql_general, rabbitmq, redis, saphana, solr_system, syslog, tcp, tomcat_access, tomcat_system, varnish, vault_audit, wildfly_system, windows_event_log, zookeeper_general].
Loading
Loading