private void ProcessClusterControllerLine(LogLine logLine)
        {
            var javaLineMatchResult = logLine.LineContents.MatchJavaLine(_clusterControllerLogsRegex);

            if (!javaLineMatchResult.SuccessfulMatch)
            {
                _processingNotificationsCollector.ReportError("Failed to process line as Cluster Controller event", logLine, nameof(ClusterControllerPlugin));
                return;
            }

            // 2018.2 linux/node1/clustercontroller_0.20182.18.0627.22308809190037074300891/logs/clustercontroller.log:333:2018-08-08 11:10:12.705 +1000 pool-18-thread-1   ERROR : com.tableausoftware.cluster.http.HttpServiceMonitor - IOException connecting to HTTP server at http://localhost:8000/favicon.ico
            if (javaLineMatchResult.IsErrorPriorityOrHigher())
            {
                var entry = new ClusterControllerError(logLine, javaLineMatchResult);
                _errorWriter.AddLine(entry);
            }

            // 2018.2 linux/node2/clustercontroller_0.20182.18.0627.22301467407848617992908/logs/clustercontroller.log:2018-08-08 15:04:51.901 +1000 Thread-6 INFO: com.tableausoftware.cluster.postgres.PostgresManager - PostgresManager stop
            if (javaLineMatchResult.Class == "com.tableausoftware.cluster.postgres.PostgresManager" &&
                _postgresMessages.ContainsKey(javaLineMatchResult.Message))
            {
                var entry = new ClusterControllerPostgresAction(logLine, javaLineMatchResult.Timestamp)
                {
                    Action = _postgresMessages.TryGetValue(javaLineMatchResult.Message, out var pm) ? pm : null,
                };

                _postgresActionWriter.AddLine(entry);
            }

            if (javaLineMatchResult.Class == "com.tableausoftware.cluster.storage.DiskSpaceMonitor" &&
                javaLineMatchResult.Message.StartsWith(DiskSpaceMonitorPrefix, StringComparison.Ordinal))
            {
                var diskSpaceStats = _diskSpaceMessageRegex.Match(javaLineMatchResult.Message);

                if (!diskSpaceStats.Success)
                {
                    _processingNotificationsCollector.ReportError("Failed to parse Cluster Controller DiskSpaceMonitor event from log line", logLine, nameof(ClusterControllerPlugin));
                    return;
                }

                long?usedSpace = diskSpaceStats.GetNullableLong("usedSpace");
                ClusterControllerDiskSpaceSample entry;

                // this if check is a workaround for the fact that DiskSpaceMonitor.java has a bug on this line
                // due to it missing the disk parameter:
                // m_logger.info("disk {}: total space={} used space={}", totalSpace, usedSpace);
                if (usedSpace != null)
                {
                    entry = new ClusterControllerDiskSpaceSample(logLine, javaLineMatchResult.Timestamp)
                    {
                        Disk       = diskSpaceStats.GetString("disk"),
                        TotalSpace = diskSpaceStats.GetNullableLong("totalSpace"),
                        UsedSpace  = diskSpaceStats.GetNullableLong("usedSpace"),
                    };
                }
                else
                {
                    entry = new ClusterControllerDiskSpaceSample(logLine, javaLineMatchResult.Timestamp)
                    {
                        Disk       = null,
                        TotalSpace = diskSpaceStats.GetNullableLong("disk"),
                        UsedSpace  = diskSpaceStats.GetNullableLong("totalSpace"),
                    };
                }

                _diskSpaceSampleWriter.AddLine(entry);
            }

            // 2018.2 linux/node2/clustercontroller_0.20182.18.0627.22301467407848617992908/logs/clustercontroller.log:262:2018-08-08 12:11:23.531 +1000 pool-25-thread-1   INFO  : com.tableausoftware.cluster.storage.DiskIOMonitor - disk I/O 1min avg > device:/dev/vda1, reads:0.00, readBytes:0.00, writes:0.35, writeBytes:7645.87, queue:0.00
            // 2018.2_windows/node1/clustercontroller_0.20182.18.1001.2115746959230678183412/logs/clustercontroller.log:5:2018-10-03 00:02:46.613 +0000 pool-24-thread-1   INFO  : com.tableausoftware.cluster.storage.DiskIOMonitor - disk I/O 1min avg > device:C:\, reads:0.00, readBytes:0.00, writes:0.00, writeBytes:0.00, queue:0.00
            if (javaLineMatchResult.Severity == "INFO" &&
                javaLineMatchResult.Class == "com.tableausoftware.cluster.storage.DiskIOMonitor" &&
                javaLineMatchResult.Message.StartsWith(DiskIoMonitorMessagePrefix, StringComparison.Ordinal))
            {
                var diskStats = _diskIoMessageRegex.Match(javaLineMatchResult.Message);

                if (!diskStats.Success)
                {
                    _processingNotificationsCollector.ReportError("Failed to parse Cluster Controller DiskIOMonitor event from log line", logLine, nameof(ClusterControllerPlugin));
                    return;
                }

                // Numbers logged in this even are locale-specific, so we need to use method with normalization on them. Only ClusterController logs appear to log locale-sensitive numbers
                var entry = new ClusterControllerDiskIoSample(logLine, javaLineMatchResult.Timestamp)
                {
                    Device           = diskStats.GetString("device"),
                    ReadsPerSec      = diskStats.GetNullableDoubleWithDelimiterNormalization("reads"),
                    ReadBytesPerSec  = diskStats.GetNullableDoubleWithDelimiterNormalization("readBytes"),
                    WritesPerSec     = diskStats.GetNullableDoubleWithDelimiterNormalization("writes"),
                    WriteBytesPerSec = diskStats.GetNullableDoubleWithDelimiterNormalization("writeBytes"),
                    QueueLength      = diskStats.GetNullableDoubleWithDelimiterNormalization("queue"),
                };

                _diskIOSampleWriter.AddLine(entry);
            }
        }
Exemplo n.º 2
0
        private void ProcessClusterControllerLine(LogLine logLine)
        {
            var match = logLine.LineContents.CastToStringAndRegexMatch(_clusterControllerLogsRegex);

            if (match == null || match == Match.Empty)
            {
                _processingNotificationsCollector.ReportError("Failed to process line as Cluster Controller event", logLine, nameof(ClusterControllerPlugin));
                return;
            }

            var groups  = match.Groups;
            var ts      = groups["ts"].Value;
            var sev     = groups["sev"].Value;
            var @class  = groups["class"].Value;
            var message = groups["message"].Value;

            // 2018.2 linux/node1/clustercontroller_0.20182.18.0627.22308809190037074300891/logs/clustercontroller.log:333:2018-08-08 11:10:12.705 +1000 pool-18-thread-1   ERROR : com.tableausoftware.cluster.http.HttpServiceMonitor - IOException connecting to HTTP server at http://localhost:8000/favicon.ico
            if (sev == "ERROR" || sev == "FATAL")
            {
                var entry = new ClusterControllerError(logLine, ts)
                {
                    Severity = sev,
                    Message  = message,
                    Class    = @class,
                };

                _errorWriter.AddLine(entry);
            }

            // 2018.2 linux/node2/clustercontroller_0.20182.18.0627.22301467407848617992908/logs/clustercontroller.log:2018-08-08 15:04:51.901 +1000 Thread-6 INFO: com.tableausoftware.cluster.postgres.PostgresManager - PostgresManager stop
            if (@class == "com.tableausoftware.cluster.postgres.PostgresManager" &&
                _postgresMessages.ContainsKey(message))
            {
                var entry = new ClusterControllerPostgresAction(logLine, ts)
                {
                    Action = _postgresMessages.TryGetValue(message, out var pm) ? pm : null,
                };

                _postgresActionWriter.AddLine(entry);
            }

            // 2018.2 linux/node2/clustercontroller_0.20182.18.0627.22301467407848617992908/logs/clustercontroller.log:262:2018-08-08 12:11:23.531 +1000 pool-25-thread-1   INFO  : com.tableausoftware.cluster.storage.DiskIOMonitor - disk I/O 1min avg > device:/dev/vda1, reads:0.00, readBytes:0.00, writes:0.35, writeBytes:7645.87, queue:0.00
            // 2018.2_windows/node1/clustercontroller_0.20182.18.1001.2115746959230678183412/logs/clustercontroller.log:5:2018-10-03 00:02:46.613 +0000 pool-24-thread-1   INFO  : com.tableausoftware.cluster.storage.DiskIOMonitor - disk I/O 1min avg > device:C:\, reads:0.00, readBytes:0.00, writes:0.00, writeBytes:0.00, queue:0.00
            if (sev == "INFO" &&
                @class == "com.tableausoftware.cluster.storage.DiskIOMonitor" &&
                message.StartsWith(DiskIoMonitorMessagePrefix, StringComparison.Ordinal))
            {
                var diskStats = _diskIoMessageRegex.Match(message);

                if (!diskStats.Success)
                {
                    _processingNotificationsCollector.ReportError("Failed to parse Cluster Controller DiskIOMonitor event from log line", logLine, nameof(ClusterControllerPlugin));
                    return;
                }

                // Numbers logged in this even are locale-specific, so we need to use method with normalization on them. Only ClusterController logs appear to log locale-sensitive numbers
                var entry = new ClusterControllerDiskIoSample(logLine, ts)
                {
                    Device           = diskStats.GetString("device"),
                    ReadsPerSec      = diskStats.GetNullableDoubleWithDelimiterNormalization("reads"),
                    ReadBytesPerSec  = diskStats.GetNullableDoubleWithDelimiterNormalization("readBytes"),
                    WritesPerSec     = diskStats.GetNullableDoubleWithDelimiterNormalization("writes"),
                    WriteBytesPerSec = diskStats.GetNullableDoubleWithDelimiterNormalization("writeBytes"),
                    QueueLength      = diskStats.GetNullableDoubleWithDelimiterNormalization("queue"),
                };

                _diskIOSampleWriter.AddLine(entry);
            }
        }