News for hackers. Stuff that matters.
Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by sciurus on Wednesday December 19, 2018 @12:13PM (#18717229)
Looking at this architecture, I wonder if it would make sense to replace Prometheus itself with something simpler? Normally Prometheus pulls metrics, evaluates rules against them, stores them, and answers queries on them. It looks like in Cortex the latter three functions are handled by other services, and Prometheus is just pulling and forwarding metrics.

Also, the article says Cortex "completes" Prometheus. While it does fill many of the gaps, there is still a big one: First-class support for pushing metrics. This seems especially important if you want to offer Prometheus as SaaS. Your customers won't want to run their own Prometheus installs (that's what they pay you for, after all), and asking customers to open their firewalls so that your Prometheus can discover and scrape their infrastructure is probably a non-starter.

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by deforciant on Wednesday December 19, 2018 @01:14PM (#18717833)
I am not sure why are you saying that the customers don't want to run their own instances as they are very lightweight. It makes architecture really flexible as one Prom instance can scrape whole environment. New applications just need to expose /metrics endpoint and set some annotations on their deployment manifests. The main problems with running Prometheus yourself are just storage capacity and query speed.

I played with Cortex for a bit, built my own gateway to match & assign user IDs for incoming Prometheus push requests but from operational perspective running Cortex can be very expensive (if you want it just as a side project) :) GCP Bigtable seems like the best way to store & query data but even the dev instance is prohibitively expensive (last time I checked it was ~1k USD)

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by sciurus on Wednesday December 19, 2018 @02:10PM (#18718384)
At that point you're just treating Prometheus as an agent, like telegraf or collectd, running in the customers infrastructure to collect metrics from it and publish them to Cortex. That gets to my first point that Prometheus does a lot more than that, so maybe it would be beneficial to replace it or strip it down to ensure your customer never has to worry about storage performance, for example.

It's flexible for some architectures, but not others. If your potential customer runs their own servers or something like k8s that they can deploy Prometheus to, sure. But what if your potential customer runs on a PaaS like Heroku? Or a FaaS like lambda? Or what if what they primarily care about getting metrics from are jobs on some managed data processing service, like cloud dataflow? Etc.

In the end, to offer Prometheus/Cortex as a SaaS and be competitive with existing players like Datadog, SignalFX, etc I'd expect you'd have to run an API that your customers can code against to push data to you.

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by slgeorge on Wednesday December 19, 2018 @04:36PM (#18719935)

  maybe it would be beneficial to replace it or strip it down to ensure your customer never has
 to worry about storage performance, for example.
The way the user runs it means that they don't store any metrics locally. The Prometheus agent on the cluster does scraping and then sends the data immediately up to the central SaaS instance (Cortex).

  what if your potential customer runs on a PaaS like Heroku
The range of exporters is very extensive (https://prometheus.io/docs/instrumenting/exporters/). And, as K8s has become so important lots of other people are publishing Prometheus metrics.

  In the end, to offer Prometheus/Cortex as a SaaS and be competitive with existing players
  like Datadog, SignalFX, etc I'd expect you'd have to run an API that your customers can code 
  against to push data to you.
Cortex provides a scalable backend storage for Prometheus metrics, it's designed as one component that someone running at large scale or a SaaS vendors needs. Your comparison isn't apples to apples.

In Weaveworks case we've build integrations into our product that help connect and pull data from other systems. Overall I think Prometheus metrics have a strong future, and there will be lots of SaaS options for sending and consuming the data.

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by sciurus on Wednesday December 19, 2018 @05:08PM (#18720238)
> The way the user runs it means that they don't store any metrics locally

Ah, that's great! I was mistakenly assuming that Prometheus would still have to write the data to disk; I didn't realize you could disable local storage.

> The range of exporters is very extensive

Sure, but that doesn't solve the problem that your heroku dyno, or lambda function, etc cannot expose metrics for Prometheus to pull, but it could easily push metrics somewhere.

> it's designed as one component that someone running at large scale or a SaaS vendors needs. Your comparison isn't apples to apples.

That's fair; I was thinking of Cortex as something to adopt off the shelf, instead of something to integrate with. However, as a SaaS provider you can always build more custom functionality alongside Cortex instead of making it a direct part of the open-source project.

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by bboreham on Thursday December 20, 2018 @03:48AM (#18723389)
> I didn't realize you could disable local storage.

You are correct: there is no option to disable so we set to discard after 2 hours. Prometheus doesn’t write continuously to disk so the io is not noticeable.

To your original question, yes we could produce another agent from the Prometheus code which did discovery, scraping and sending but not disk storage. We choose not to as it’s another thing to maintain.

Also we want an option to queue on disk when the network link to push is down.

(I am a Cortex maintainer)

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by netingle on Wednesday December 19, 2018 @06:22PM (#18720932)
> I'd expect you'd have to run an API that your customers can code against to push data to you.

Thats a good point; Cortex does accept pushes of metrics but its not that simple, and its definitely not easy right now. We're going to be working with the OpenMetrics project to have a better story about push and serverless - I expect we'll have this pretty soon, ie a matter of months.

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by netingle on Wednesday December 19, 2018 @06:19PM (#18720908)
Nice! I agree Cortex's operational overhead can be quite high. Good news! We are going to fix that. We've got PRs open to add local storage (based on BoltDB) to remove the dependancy on DynamoDB/Bigtable, and I've almost finished a single binary, non-microservices version of Cortex.

If you want a sneak peak, checkout grafana/loki; its based on Cortex and has all theses features - buts it for logs, not metrics.

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by grumpydba on Thursday December 20, 2018 @02:29AM (#18723100)
Hi,

It is my understanding that Prometheus's storage engine is LSM based, and uses a compression scheme inspired by gorilla.

Boltdb is basically a btree which causes more write amplification.

Maybe you should try badgerdb.

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by bboreham on Thursday December 20, 2018 @03:39AM (#18723352)
Cortex also uses gorilla-inspired compression, using the Prometheus source code.

After compressing timeseries they are stored and indexed using a database-like thing, typically DynamoDB or Bigtable, but soon BoltDB will be an option.

(I am a Cortex maintainer)

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by slgeorge on Wednesday December 19, 2018 @04:20PM (#18719755)

  This seems especially important if you want to offer Prometheus as SaaS. 
  Your customers won't want to run their own Prometheus installs (that's what they pay you for, after all), 
  and asking customers to open their firewalls so that your Prometheus can discover and scrape their 
  infrastructure is probably a non-starter.
At Weaveworks we provide Prometheus as a SaaS using Cortex, which is how the project was started. For our service we have an agent that installs a Prometheus agent (and some other ones) on the customers K8s cluster.

The upsides of running the agent on their side is that they benefit from Prometheus' automatic service discovery. They can also use standard Prometheus configuration and scrapers to get the full capabilities for their environment.

There are also situations where the user wants to continue to run their own Prometheus, but down sample and send a limited number of metrics for long-term storage in the Weave Cloud SaaS. This can be done with one line in a standard Prometheus.

It's true that running the agent takes resources, I think the benefits are worth it. For most people the key question is getting the full value from their metrics data to enable better development and operations.

[NOTE]: Full Disclosure I work at Weaveworks where we provide Prometheus-as-a-Service (https://www.weave.works/features/prometheus-monitoring/)

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by NikolaeVarius on Wednesday December 19, 2018 @01:10PM (#18717800)
Supporting push metrics is not a Gap. It is literally the design goal of Prometheus to have a pull based metrics model.
Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by netingle on Wednesday December 19, 2018 @06:14PM (#18720871)
Whatsmore, Cortex is push based...
Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by netingle on Wednesday December 19, 2018 @06:16PM (#18720884)
I recently opened a PR to add support for pushing metrics to Cortex from Telegraf, so you don't need Prometheus as the agent: https://github.com/influxdata/telegraf/pull/5003

NB I'm the main author of Cortex...

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by GauntletWizard on Wednesday December 19, 2018 @12:40PM (#18717522)
Prometheus is winning because push-based metrics are the wrong approach. Integration with service discovery to tell if your metrics are operating or not is, in my experience, the #2 or #3 preventer of outages.
Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by comboy on Wednesday December 19, 2018 @01:58PM (#18718249)
I love Prometheus but in some cases push-based metrics have they advantages. E.g. I'm using push based system in my home automation, where apart from metrics (stats of temp and humidity) it also works as a state machine (door open, switch off) so that I can build logic on top of that by listening to changes. I think having realtime data helps in evaluating some server problems too. Obviously everything depends on use case and not every solution scales well.

Re having downtime indicator that's really a few lines of code, if no event received in the last X seconds then the host is down or busy enough to need attention. With websocket connection you can react to such downtime pretty much immediately instead of waiting for the next poll.

I know there are workarounds but I really wish Prometheus would support some push based system out of the box. It also helps with tracking simple scripts that only run occasionally etc. And yes, I know, they provide workarounds, the docs are really good.

It seems to me that having a realtime system with push based metrics is cheap enough that we should have it already. Imagine ideal monitoring system of the future. Does it poll and refresh data every so often or are you able to see everything as it's happening?

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by sciurus on Wednesday December 19, 2018 @01:50PM (#18718181)
If I had to speculate why Prometheus is doing well, I'd put the simplicity of deployment and ongoing operations first, and probably the great integration with Kubernetes second.

I think that if it had gone with a push-based model it would have been just as successful.

Push vs Pull is unrelated to integrating service discovery. Right now I push metrics to Datadog. It can tell if my metrics are operating or not, because it's aware of the state of the Datadog agent and of what the EC2 API reports.

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by hangonhn on Wednesday December 19, 2018 @01:45PM (#18718127)
There are reasons for push-vs-pull but one huge advantage of pull vs push is that you're less likely to get overwhelmed by useless metrics. You have to make a very deliberate decision to take the metrics you want. It also makes sense that the observer decides what to observe.

Also, if you really, really want push, there's always the push gateway in the Prometheus tool kit. Also, you can use Telegraf from InfluxDB with Prometheus.

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by postwait on Wednesday December 19, 2018 @09:23PM (#18722008)
I think this misrepresents the pull vs. push issue.

I wrote something up two years about this that was pretty well received. https://www.circonus.com/2016/06/pully-mcpushface/

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by hangonhn on Wednesday December 19, 2018 @11:42PM (#18722562)
Thanks for that amazing insight! Super helpful. I like how you framed your thinking.
Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by SlowRobotAhead on Wednesday December 19, 2018 @04:13PM (#18719690)
Off topic, but Cortex is bad name.

There is already an amazingly popular tech usage of Cortex, you almost certainly have one either on your person or feet from you night now.

For SEO reasons alone it makes no sense to call your new service by a well known name belonging to someone else.

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by lima on Wednesday December 19, 2018 @08:08PM (#18721654)
What's the current state of the art for space-efficient long term Prometheus storage?

PromHouse looks very promising: https://github.com/Percona-Lab/PromHouse

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by csmarchbanks on Wednesday December 19, 2018 @08:40PM (#18721812)
Thanos (https://github.com/improbable-eng/thanos) or Cortex are both great projects depending on your needs.

I would be wary of PromHouse since at a glance it seems to be storing each timestamp in a separate row, which will not be as space efficient as either of the above options.

Full disclosure, I am a maintainer of the Cortex project.

Re:Cortex: a multi-tenant, horizontally scalable Prometheus-... by postwait on Wednesday December 19, 2018 @09:19PM (#18721994)
IRONdb (https://www.irondb.io/)

Can house multi-tenant-safe prometheus long-tail storage as well as others (graphite, opentsdb, influx, etc.). Put it all in one place, scale it up, radically storage efficient and has strong non-stop HA guarantees. It is state of the art, it isn't free.

Disclaimer: I'm the CEO of Circonus (IRONdb's home).