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 collection time bucket to GroupedTableAppenderResponse #33

Open
zikato opened this issue Dec 14, 2023 · 4 comments
Open

Add collection time bucket to GroupedTableAppenderResponse #33

zikato opened this issue Dec 14, 2023 · 4 comments

Comments

@zikato
Copy link

zikato commented Dec 14, 2023

I'd like to trend aggregated data for insights over time.

Example:

XE definition

create event session wait_info on server
add event sqlos.wait_info
(
    where opcode = 'end'
)

json config (simplified)

{
    "Target": {
        "ServerName": "server",
        "SessionName": "wait_info ",
        "FailOnProcessingError": false,
        "Responses": [
            {
                "__type": "GroupedTableAppenderResponse",
                "ServerName": "localhost",
                "DatabaseName": "XeSmartTarget",
                "TableName": "WaitInfoHistogram",
                "AutoCreateTargetTable": true,
                "UploadIntervalSeconds": 10,
                "Events": [
                    "wait_info"
                ],
                "OutputColumns": [
                    "database_id",
                    "MAX(collection_time) AS max_collection_time", 
                    "SUM(duration) AS sum_duration_ms"
                ]
            }
        ]
    }
}

Current

It will group by database_id sum duration of waits. For each collection it will then merge with what's in the table so I get total waits per DB since the collection started (similar to how SQL Server tracks wait stats since last restart)

Ideal

Introduce a date bucket syntax for the collection_time column
For example:

So instead of collection_time , I'd have something like bin(collection_time, 5m) and have the aggregates in 5-minute intervals.

@zikato
Copy link
Author

zikato commented Dec 14, 2023

Another option: the UploadIntervalSeconds would be the bin size, and I could have the option not to merge with the target table.
So it would still be grouped and aggregated within the XE Smart Target, but only appended to the target table.

@spaghettidba
Copy link
Owner

That's an interesting feature. I tried to achieve the same with SUBSTRING(CONVERT(collection_time,'System.String'),1,16) but I understand that this depends on the time format of the machine where XESmartTarget is running.
The main problem is that the expressions are based on what the DataTable class can accept. It has its own syntax and there are things it can't do. I'll see if I can find a way.
Thanks for filing this issue!

@zikato
Copy link
Author

zikato commented Dec 15, 2023

Thank you! In that case, I think my second post could be used as a workaround - appending to the target table instead of merging and using the Upload interval as the time bucket (along with max(collection_time))

@spaghettidba
Copy link
Owner

Sure, this can be done! Let me work out something and I'll get back to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants