Giter Club home page Giter Club logo

carbonsearch's Introduction

Build Status

carbonsearch: graphite-shaped search queries

CarbonSearch is a search service for graphite that allows for querying metrics by attributes other than the metric name.

It takes a fake 'metric' like:

virt.v1.*.lb-pool:www.discovery-live:true.server-state:installed

and resolves it to a set of metrics, which were previously tagged to match these characteristics (right now using AND semantics).

Query language

The query language is just a set of AND'd key-value pairs. Each key-value pair has a prefix that indicates the data source, like lb-pool for load balancer pool, or discovery-live for service discovery liveness. The token as a whole (lb-pool:www) is called a tag.

Text queries

There's a special "tag" for querying by the text name of the metric: text-match.

virt.v1.*.text-match:Delay.lb-pool:db

This will take all metrics tagged with lb-pool:db and have 'Delay' in their name. Depending on your data, you might end up with a bunch of metrics about replication delay in the db pool.

Configuration and Running

See *.example.yaml for complete example configs with comments. Just cp to $config_name.yaml to use for real.

carbonsearch.yaml

Requires -config to specify a carbonsearch.yaml, defaults to in the running directory. The consumers key specifies which consumers should be started by carbonsearch.

For example,

consumers:
    httpapi: "httpapi.yaml"

Would only start the HTTP API consumer, not the Kafka one.

Where it runs

This is an in-memory service intended to run on CarbonZipper hosts. consuming from a handful of Kafka topics to populate the index. It resolves virtual namespace queries from carbon zipper into lists of real metrics.

Populating the index by sending messages

The search index is populated by consuming messages (via Kafka, HTTP API, etc.). There are 3 types of messages: metrics, tags, and custom.

Metric messages

Metric messages associate an arbitrary number of metrics with a value of a join key.

In this case, the join key is fqdn, and the join key value is hostname-1234.

{
  "value": "hostname-1234",
  "metrics": [
    "server.hostname-1234.cpu.i7z"
  ],
  "key": "fqdn"
}

Tag messages

Tag messages associate an arbitrary number of tags with a value of a join key.

{
  "value": "hostname-1234",
  "tags": [
    "server-state:live",
    "server-dc:lhr",
    "server-role:webserver"
  ],
  "key": "fqdn"
}

Custom messages

Custom messages directly associate an arbitrary number of tags with an arbitrary number of metrics.

This allows humans to create custom groupings to easily search.

{
  "metrics": [
    "monitors.lb_pool.www.lhr",
    "monitors.is_the_site_up",
    "server.hostname-1234.cpu.i7z"
  ],
  "tags": [
    "custom-favorites:monitoring"
  ]
}

Acknowledgement

This program was originally developed for Booking.com. With approval from Booking.com, the code was generalised and published as Open Source on github, for which the author would like to express his gratitude.

License

This code is licensed under the MIT license.

carbonsearch's People

Contributors

dgryski avatar kanatohodets avatar nnuss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

carbonsearch's Issues

autocomplete doesn't work with grafana

Autocomplete has been tested working with graphite-web 0.9 series, but it is broken with grafana.

At first glance this is because grafana doesn't tack the glob on the end of the completion query that graphite-web does, so the heuristic in carbonsearch to detect autocomplete queries does not trigger.

It seems that carbonsearch gets confused by kafka topic truncation

If you truncate the kafka topic while carbonsearch trying to do initial warm-up, then carbonsearch gets confused and newer reach the warm state.

2018/02/22 19:19:32 kafka consumer: topic sm_metrics 92.31% warm (threshold is 99.00%)
2018/02/22 19:19:42 kafka consumer: topic sm_metrics 92.31% warm (threshold is 99.00%)
2018/02/22 19:19:52 kafka consumer: topic sm_metrics 92.32% warm (threshold is 99.00%)
2018/02/22 19:20:02 kafka consumer: topic sm_metrics 92.32% warm (threshold is 99.00%)
2018/02/22 19:20:12 kafka consumer: topic sm_metrics 92.33% warm (threshold is 99.00%)
2018/02/22 19:20:22 kafka consumer: topic sm_metrics 92.33% warm (threshold is 99.00%)
2018/02/22 19:20:32 kafka consumer: topic sm_metrics 92.33% warm (threshold is 99.00%)
2018/02/22 19:20:42 kafka consumer: topic sm_metrics 92.33% warm (threshold is 99.00%)
.....truncation happen....
2018/02/26 17:01:51 kafka consumer: topic sm_metrics 92.33% warm (threshold is 99.00%)

Search for tags by metric name.

It a nice feature to have. Query could be done via HTTP API call.
The use-case is to find where does this metric come from.
What do you think?

Support curly brackets in name

For example we are doing searches like:
virt.v1.*.role:foo.status:{live,installed}.cluster:{cluster1,cluster2,cluster3}.text-match:metrics_received

This should be treated as a 6 requests for {live,installed} X {cluster1,cluster2,cluster3} and return 6 different results.

proposal: `.text-match:{substring.with.dots}`

This adds known meta-characters that are already valid in find queries to allow substring matching for text including dots.

The query parsing is not longer a single split command but is still easy to handle.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.