public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData)
        {
            WaLinuxAgentLogParsedResult parsedResult = tableData.QueryOutput <WaLinuxAgentLogParsedResult>(
                DataOutputPath.Create(SourceParserIds.WaLinuxAgentLog, WaLinuxAgentDataCooker.CookerId, "ParsedResult"));
            var logEntries = parsedResult.LogEntries;

            var baseProjection = Projection.Index(logEntries);

            var fileNameProjection   = baseProjection.Compose(x => x.FilePath);
            var lineNumberProjection = baseProjection.Compose(x => x.LineNumber);
            var eventTimeProjection  = baseProjection.Compose(x => x.EventTimestamp);
            var logLevelProjection   = baseProjection.Compose(x => x.LogLevel);
            var logProjection        = baseProjection.Compose(x => x.Log);

            //
            // Table Configurations describe how your table should be presented to the user:
            // the columns to show, what order to show them, which columns to aggregate, and which columns to graph.
            // You may provide a number of columns in your table, but only want to show a subset of them by default so as not to overwhelm the user.
            // The user can still open the table properties in UI to turn on or off columns.
            // The table configuration class also exposes four (4) columns that UI explicitly recognizes: Pivot Column, Graph Column, Left Freeze Column, Right Freeze Column
            // For more information about what these columns do, go to "Advanced Topics" -> "Table Configuration" in our Wiki. Link can be found in README.md
            //

            var config = new TableConfiguration("Default")
            {
                Columns = new[]
                {
                    LogLevelColumn,
                    TableConfiguration.PivotColumn,
                    LineNumberColumn,
                    LogColumn,
                    EventTimestampDateTimeColumn,
                    TableConfiguration.GraphColumn,
                    EventTimestampColumn,
                },
                Layout = TableLayoutStyle.GraphAndTable,
            };

            config.AddColumnRole(ColumnRole.StartTime, EventTimestampColumn);

            //
            //
            //  Use the table builder to build the table.
            //  Add and set table configuration if applicable.
            //  Then set the row count (we have one row per file) and then add the columns using AddColumn.
            //
            tableBuilder
            .AddTableConfiguration(config)
            .SetDefaultTableConfiguration(config)
            .SetRowCount(logEntries.Count)
            .AddColumn(FileNameColumn, fileNameProjection)
            .AddColumn(LineNumberColumn, lineNumberProjection)
            .AddColumn(EventTimestampColumn, eventTimeProjection)
            .AddColumn(LogLevelColumn, logLevelProjection)
            .AddColumn(LogColumn, logProjection);
        }
Exemplo n.º 2
0
        public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData)
        {
            WaLinuxAgentLogParsedResult parsedResult = tableData.QueryOutput <WaLinuxAgentLogParsedResult>(
                DataOutputPath.ForSource(SourceParserIds.WaLinuxAgentLog, WaLinuxAgentDataCooker.CookerId, nameof(WaLinuxAgentDataCooker.ParsedResult)));
            var fileNames          = parsedResult.FileToMetadata.Keys.ToArray();
            var fileNameProjection = Projection.Index(fileNames.AsReadOnly());

            var lineCountProjection = fileNameProjection.Compose(
                fileName => parsedResult.FileToMetadata[fileName].LineCount);

            tableBuilder.SetRowCount(fileNames.Length)
            .AddColumn(FileNameColumn, fileNameProjection)
            .AddColumn(LineCountColumn, lineCountProjection);
        }