robertuxo
robertuxo

Reputation: 35

Extract unique Tags and Count

Good morning,

I am trying to run a kusto Query to display unique owner tags to show in a chart the amount of times an owner shows up in azure. I want to have all the distinct owners and cost centers show up but am having trouble figuring out the best way to do that.Below is an example but I need to specify multiple owners to produce a chart that shows all the unique owners in Azure

resources | where tags['owner'] =~ "Billy" | summarize count()

Upvotes: 0

Views: 1002

Answers (2)

disolve
disolve

Reputation: 1

Try using 'has' which is case insensitive

resources
| extend owner = tags has 'owner'
| summarize count() by owner

Upvotes: 0

Yoni L.
Yoni L.

Reputation: 25895

This should give you a direction. You'll need to do something similar for the "cost center" property (or update your question to elaborate on which part of your data set it comes from)

resources
| extend owner = tostring(tags.owner)
| summarize count() by owner
| render barchart // you can choose a different type of chart

given your modified description: If I have two sets of tags one that is (Owner) and the other is (owner) how would I combine them together in the query? -> you could do this (assuming you can't fixed the source data, which would be better):

union (
    resources
    | extend owner = tostring(tags.owner) // lowercase 'o' in 'tags.owner'
    | summarize count() by owner
), (
    resources
    | extend owner = tostring(tags.Owner) // uppercase 'O' in 'tags.Owner'
    | summarize count() by owner
)
| summarize sum(count_) by owner

Upvotes: 1

Related Questions