openTSDB query for metrics which dont have a tag - opentsdb

is there any way to query for metric values that dont have a tag?for example metric1 is logged with tag1, tag2 or with only tag1.How can i get all the graphs that have just tag1nd not the one that have both tag1 nd tag2?

If you specify a value for tag2 (even just tag2=*), then only data points that have that tag will be returned.

While this wasn't possible at the time you asked, there is the explicitTags flag since version 2.3, which does exactly what you want:
For metrics with varying tags, this can be used to avoid aggregating
time series that should not be included in the final result.
Not related to you question, but It can also be used to optimize the query, according to the docs:
As of 2.3 and later, if you know all of the tag keys for a given
metric query latency can be improved greatly by using the explicitTags
feature. This flag has two benefits:
For metrics that have a high cardinality, the backend can switch to a
more efficient query to fetch a smaller subset of data from storage.
(Particularly in 2.4)

Your question (if I have understood it as, what you meant) - you have a timeseries:
{metric: metric1, timestamp: 123467789, value: 32, tags:{tag1:foo, tag2:bar}}
To query:
/api/query??start=1h-ago&m=sum:metric1{tag1=foo,tag2=bar}
But what you want is the data points - only with tag1:
{metric: metric1, timestamp: 123467789, value: 32, tag1:foo}
Answer:
I didn't find any solution - but have a suggestion. You can make it work by introducing a third tag i.e. tag3 set it to 1 in case of no tag2:
{metric: metric1, timestamp: 123467789, value: 32, tags:{tag1:foo, tag3:bar}}
Now you can query only the points with tag1 (no tag2):
/api/query??start=1h-ago&m=sum:metric1{tag1=foo,tag3=1}
PS Or you can specify a fixed value for tag2 i.e. 0 in case of no value.

Related

How do I simple calculations in CosmosDB using GremlinAPI

I am using CosmosDB with GremlinAPI and I would like to perform simple calculation even though CosmosDB does not support the math step.
Imagine that I have vertex "Person" with the property Age that can have a edge "Owns" to another vertex "Pet" that also has the property Age.
I would like to know if a given person has a cat that is younger than the person but not more than 10 years younger.
The query (I know this is just a part of it but this is where my problem is)
g.V().hasLabel("Person").has("Name", "Jonathan Q. Arbuckle").as("owner").values("age").inject(-10).sum().as("minAge").select("owner")
Returns an empty result but
g.V().hasLabel("Person").has("Name", "Jonathan Q. Arbuckle").as("owner").values("age").inject(-10).as("minAge").select("owner")
Returns the selected owner.
It seems that if I do a sum() or a count() in the query, then I cannot do 'select("owner")' anymore.
I do not understand this behaviour. What should I do to be able to do a 'select("owner")' and be able to filter the Pets based on their age.
Is there some other way I can write this query?
Thank you in advance
Steps like sum, count and max are known as reducing barrier steps. They cause what has happened earlier in the traversal to essentially be forgotten. One way to work around this is to use a project step. As I do not have your data I used the air-routes data set and used airport elevation as a substitute for age in your graph.
gremlin> g.V(3).
project("elev","minelev","city").
by("elev").
by(values("elev").inject(-10).sum()).
by("city")
==>[elev:542,minelev:532,city:Austin]
I wrote some notes about reducing barrier steps here: http://kelvinlawrence.net/book/PracticalGremlin.html#rbarriers
UPDATED
If you wanted to find airports with an elevation less than the starting airport by no more than 10 and avoiding the math step you can use this formulation.
g.V(3).as('a').
project('min').by(values('elev').inject(-10).sum()).as('p').
select('a').
out().
where(lt('a')).by('elev').
where(gt('p')).by('elev').by('min')

Grouping, missing data - Cognos Report Studio

In IBM Cognos Report Studio
I have a data structure like so, plain dump of the customer details:
Account|Type|Value
123-123| 19 |2000
123-123| 20 |2000
123-123| 21 |3000
If I remove the Type from my report I get:
Account|Value
123-123|2000
123-123|3000
It seems to have treated the two rows with an amount '2000' as some kind of duplicated amount and removed it from my report.
My assumption was that Cognos will aggregate the data automatically?
Account|Value
123-123|8000
I am lost on what it is doing. Any pointers? If it is not grouping it, I would at least expect 3 rows still
Account|Value
123-123|2000
123-123|2000
123-123|3000
In any case I would like to end up with 1 line. The behaviour I'm getting is something I can't figure out. Thanks for any help.
Gemmo
The 'Auto-group & Summarize' feature is the default on new queries. This will find all unique combinations of attributes and roll up all measures to these unique combinations.
There are three ways to disable auto-group & summarize behavior:
Explicitly turn it off at the query level
Include a grain-level unique column, e.g. a key, in the query
Not include any measures in the query
My guess is that your problem is #3. The [Value] column in your example has to have its 'Aggregate Function' set to an aggregate function or 'Automatic' for the auto-group behavior to work. It's possible that column's 'Aggregate Function' property is set to 'None'. This is the standard setting for an attribute value and would prevent the roll up from occurring.

How to get assisted Interaction break down by date?

I'm using this query
https://www.googleapis.com/analytics/v3/data/mcf?ids=ga%3A99364917&start-date=2016-11-05&end-date=2016-12-05&metrics=mcf%3AfirstInteractionConversions&dimensions=mcf%3Asource&key={YOUR_API_KEY}
To get first interaction analysis, but I get only the summary / total. I would like to get that number by date.
Meaning instead of getting: Facebook:100, Direct: 100
I would like to get
Facebook: 12/1/16:50,12/2/16:50
Direct: 12/1/16:30, 12/2/16:70
How can I do that?
I think you can just add mcf:conversionDate to the dimensions in your query. The returned rows will then be segmented by both MCF source and conversion date.

MS Access- Calculated Column for Distinct Count in Table Rather than a Query

I'd like to have a Calculated Column in a table that counts the instances of a concatenation.
I get the following error when inputting Abs(Count([concat])) as the column formula for the calculation: The expression Abs(Count([concat])) cannot be used in a calculated column.
Is there any other way to do it without doing a query? I'm pretty sure it can't be done but I figured I'd ask anyways since I didn't see any other posts about it.
No, and even if there was, you should create and use a query for this.
Besides, applying Abs on a count doesn't make much sense, as the count cannot be negative.

What is the best way to determine what articles are available for a given usenet group?

I was wondering what the most efficient way is to get the available articles for a given nntp group. The method I have implemented works as follows:
(i) Select the group:
GROUP group.name.subname
(ii) Get a list of article numbers from the group (pushed back into a vector 'codes'):
LISTGROUP
(iii) Loop over codes and grab articles (e.g. headers)
for code in codes do
HEAD code
end
However, this doesn't scale well with large groups with many article codes.
In RFC 3977, the GROUP command is indicated as also returning the 'low' and 'high' article numbers. For example,
[C] GROUP misc.test
[S] 211 1234 3000234 3002322 misc.test
where 3000234 and 2002322 are the low and high numbers. I'm therefore thinking of using these instead rather than initially pushing back all article codes. But can these numbers be relied upon? Is 3000234 definitely indicative of the first article id in the above-selected group and likewise is 3002322 definitely indicative of the last article id in the above-selected group or are they just estimates?
Many thanks,
Ben
It turns out I was thinking about this all wrong. All I need to do is
(i) set the group using GROUP
(ii) execute the NEXT command followed by HEAD for however many headers I want (up to count):
for c : count do
articleId <-- NEXT
HEAD articleID
end
EDIT: I'm sure there must be a better way but until anyone suggests otherwise I'll assume this way to be the most effective. Cheers.

Resources