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

Tagged demo #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Tagged demo #7

wants to merge 2 commits into from

Conversation

mary3000
Copy link
Contributor

@mary3000 mary3000 commented Mar 21, 2019

This demonstrates how tagged series can be inserted in CH with carbon-clickhouse.
Also with tags I need to create more complex queries for Grafana, like

SELECT 
    $timeSeries AS t, 
    avg(Value) 
FROM graphite 
ALL INNER JOIN 
( 
    SELECT Path
    FROM graphite_tagged
    WHERE 
        Tag1 = 'a=1'  OR Tag1 = 'c=5' 
    GROUP BY (Path, Tags) 
    HAVING count(Tag1) == 2 
) USING Path 
WHERE $timeFilter 
GROUP BY t 
ORDER BY t

for selecting all series with both tag a=1 and b=5. This query selects tagged metric paths from special table (graphite_tagged) and joins it with the main (graphite) table.

Pros:

  • Simple to use
  • ...

Cons:

  • Extra memory on storing tagged data in graphite_tagged table
  • Join is not a good approach, as far as I know. It is slow.
  • ...

@code-of-kpp
Copy link
Contributor

How tags are exposed / used in grafana?

demo/generator.sh Outdated Show resolved Hide resolved
@code-of-kpp
Copy link
Contributor

Who manages graphite_tagged table and how?

@mary3000
Copy link
Contributor Author

Who manages graphite_tagged table and how?

It is managed by clickhouse-carbon, see this.

It is parsed here: all keys in the string are sorted and repeated keys are deleted. You can see in the tests examples of resulting string. It will be then added to graphite_tagged and graphite tables with this string as Path.

@code-of-kpp
Copy link
Contributor

so basically old tags are never deleted?

@mary3000
Copy link
Contributor Author

mary3000 commented Mar 24, 2019

so basically old tags are never deleted?

If I'm not mistaken, yes. It can be a problem since metrics can have a huge amount of different tags? Maybe we can drop too old partitions periodically through some demon (delete is now supported in CH)

@code-of-kpp
Copy link
Contributor

Things like tags exploding happen: when something is marked as tag by error. Just imagine more or less random data (strings and numbers) going directly to 2003 port. Suddenly you can end up with 100500+ different things labeled as tags with no semantics.
Usually it is not the case though: even if you have lots of virtual machines and/or containers popping out of nowhere with random hostnames, the tag space is likely to be small enough keep all the values forever and if lookups are cached somehow that should be fine.

@mary3000
Copy link
Contributor Author

How tags are exposed / used in grafana?

What do you mean? Grafana has no knowledge about tags in CH, I just write some query that that us using some tags for filtering.

@code-of-kpp
Copy link
Contributor

Usually people use grafana template variables for this. With template variable of type "Query" you can get a list of possible tag values. Then you can use this variable in query.

For example you can have template variable for hostname: with drop-down menu (or using GET parameters) user specifies one or more hostnames and grafana shows only data for selected hostnames.

i.e. tag values query SELECT DISTINCT tag_value FROM tags WHERE tag_key = 'hostname' AND...
and templated query SELECT hostname, time_slot, value FROM metrics WHERE match(hostname, '${hostname:regex}') AND ... GROUP BY (hostname, time_slot)

@mary3000
Copy link
Contributor Author

If these template variables rely on query, would they be automatically updated if I will insert some data that changes the result of this query (for example new tags), or I should update these templates manually after it?

@code-of-kpp
Copy link
Contributor

Grafana can update them, yes

@code-of-kpp
Copy link
Contributor

is it WIP?

@mary3000
Copy link
Contributor Author

is it WIP?

No, I added template variables.

@code-of-kpp
Copy link
Contributor

Could you please rebase?

@code-of-kpp code-of-kpp added the conflicts Author was asked to rebase label May 11, 2019
@mary3000 mary3000 force-pushed the tagged-demo branch 3 times, most recently from eb8394d to 099019e Compare May 17, 2019 17:32
@mary3000
Copy link
Contributor Author

rebased

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

Successfully merging this pull request may close these issues.

2 participants