cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Append Command

nicemukesh
Contributor

Append command is used to combine metric and log data both. When i ran below query 1 and query 2, why we are getting two different results,  even though they are fetching it for same time period.

 

Query-1

timeseries {
requests = sum(dt.kubernetes.container.requests_cpu, rollup:avg, default:0),
usage = sum(dt.kubernetes.container.cpu_usage, rollup:avg, default:0),
nonempty:true
}, by:{dt.entity.cloud_application_namespace}, from: -14d, to: now(), interval: 1m
| filter matchesPhrase(dt.entity.cloud_application_namespace,"CLOUD_APPLICATION_NAMESPACE-12345678890")

 

Query-2

 

 

timeseries {
requests = sum(dt.kubernetes.container.requests_cpu, rollup:avg, default:0),
nonempty:true
}, by:{dt.entity.cloud_application_namespace}, from: -14d, to: now(), interval: 1m

| append [
timeseries {
usage = sum(dt.kubernetes.container.cpu_usage, rollup:avg, default:0),
nonempty:true
}, by:{dt.entity.cloud_application_namespace}, from: -14d, to: now(), interval: 1m
]

| filter matchesPhrase(dt.entity.cloud_application_namespace,"CLOUD_APPLICATION_NAMESPACE-1234567890")

2 REPLIES 2

Hi @nicemukesh , both the queries should fetch the same result but the difference lies in how the query is structured . In the first query you are calculating both metrics within a single timeseries block, but in the second query you are separating them into two blocks and appending the results.

The first query would get you a single record which includes requests and usage for a specific timeframe where as the second query would get you two records one for request and other for usage for the same timeframe .

You might notice it if you are looking at it in tabular format but it will not be noticeable when visualized in a line chat or any other  chart.

Using append in your second query allows for more flexibility if you need to apply different filters or transformations to each metric before combining them as an example 

Hope this helps.

 

 

Phani Devulapalli

My question is whether we get same results or not while running both queries. If not  then what is reason?

Featured Posts