24 Matching Annotations
  1. Mar 2024
    1. PromQL Example - http requests total https://youtu.be/STVMGrYIlfg?t=417

    2. To understand Prometheus even better, let's have a look at its core features. The dimensional data model, the metrics transfer format, the query language, integrated alerting, and support for service discovery.
    3. All right, with that out of the way, let's have a look at the system architecture of a basic Prometheus monitoring setup.

      Prometheus Architecture

      https://youtu.be/STVMGrYIlfg?t=55

    1. Target

      A target is the definition of an object to scrape. For example, what labels to apply, any authentication required to connect, or other information that defines how the scrape will occur.

    2. Time Series

      The Prometheus time series are streams of timestamped values belonging to the same metric and the same set of labeled dimensions. Prometheus stores all data as time series.

      A sample is a single value at a point in time in a time series.

      In Prometheus, each sample consists of a float64 value and a millisecond-precision timestamp.

    3. throttles

      Throttle原本的意思是节流阀或者油门,用于控制流体(如汽油、空气)流动的速度或量。在汽车中,踩油门就是通过控制油门来增加燃油流向引擎的速度,从而加快车速。在计算机科学(CS)中,"throttle"这个概念被借用来表示限制或控制数据传输或处理的速率。这种概念转移是因为在两个领域中,throttle都涉及到通过调节流量来达到控制系统行为的目的。

      在Alertmanager的上下文中,throttle意味着控制警报通知的发送频率,以避免过多的通知造成接收者或者系统的负担。例如,如果有大量相似的警报被触发,而不加以控制地发送所有通知,那么接收方(比如运维团队)可能会被大量重复的信息淹没,从而难以迅速准确地响应真正重要的警报。通过throttling,Alertmanager可以合理地控制通知的发送,确保信息的有效传达而不造成不必要的干扰。

    1. 要直接抓取on-premise服务的metrics,你需要掌握以下几个关键领域的知识:

      1. Prometheus基础知识

      • 理解Prometheus架构:了解Prometheus的组件,包括Prometheus服务器、服务发现、抓取(scrape)配置、存储、查询语言(PromQL)等。
      • 配置抓取(Scrape):熟悉如何配置Prometheus的抓取任务,包括设置抓取间隔、超时时间、目标服务的metrics路径等。
      • Prometheus配置文件:了解Prometheus的配置文件结构,能够编写或修改配置文件以添加或修改抓取任务。

      2. 网络知识

      • 网络可达性:确保Prometheus服务器能够访问on-premise服务的网络地址。这可能涉及到配置网络路由、防火墙规则等。
      • 安全通信:如果metrics需要安全传输(推荐),了解如何配置HTTPS或其他加密方法。

      3. 安全性和认证

      • 认证机制:如果on-premise服务的metrics端点需要认证,了解如何在Prometheus的抓取配置中设置认证信息。这可能包括基本认证、Bearer Token认证或其他自定义认证机制。
      • TLS/SSL:了解如何为Prometheus配置TLS证书,以安全地抓取支持HTTPS的服务。

      4. on-premise服务的监控和metrics暴露

      • 服务配置:了解如何在你的on-premise服务中启用和配置metrics的暴露。这通常涉及到在应用中集成Prometheus客户端库,并在特定端口和路径上暴露metrics。
      • Metrics命名和组织:了解Prometheus的metrics命名规范和最佳实践,以确保你的metrics易于理解和查询。

      5. PromQL和仪表盘

      • 查询语言(PromQL):了解如何使用PromQL查询语言来检索和分析metrics数据。
      • 可视化和仪表盘:熟悉如何使用Grafana或Prometheus自带的UI来创建仪表盘,以可视化和监控你的metrics数据。

      实践步骤

      具体到操作层面,设置Prometheus直接抓取on-premise服务的metrics大致需要以下步骤:

      1. 确保服务可达:确保Prometheus实例能够网络访问到on-premise服务。
      2. 配置metrics暴露:在你的on-premise服务中启用metrics暴露,通常是在特定的HTTP端点。
      3. 添加抓取配置:在Prometheus配置文件中添加一个新的抓取任务,指向你的on-premise服务的metrics端点。
      4. 配置安全性(如果需要):根据需要为抓取任务配置HTTPS、认证等。
      5. 重启Prometheus(如果需要):应用新的配置后,根据你的部署方式,可能需要重启Prometheus服务。
      6. 验证和调整:使用Prometheus UI或Grafana验证metrics是否被正确抓取,并根据需要调整抓取配置或metrics暴露。

      掌握这些知识和步骤后,你应该能够有效地配置Prometheus直接抓取你的on-premise服务的metrics。

    2. "Federation"(联邦)这个术语在Prometheus的上下文中被用来描述一种特定的数据聚合模式,它允许从多个Prometheus实例中汇总数据到一个中心实例。这个概念源于更广泛的联邦理念,即不同实体(在这种情况下是Prometheus服务器)保持相对的自治,同时共享一些资源或数据以实现更大的目标。

      概念内涵

      在政治和组织领域,联邦是由几个部分或州组成的一个单一实体,这些部分或州在某些方面保持自主,但在其他方面共享共同的中央政府或组织。这个概念转移到数据管理和监控领域时,有以下含义:

      • 自治性:每个Prometheus实例可以独立监控其负责的特定服务或基础设施部分。这意味着每个实例可以有其自己的配置、规则、警报和存储策略,适应其监控目标的特定需求。
      • 共享:虽然每个实例都是自治的,但它们通过联邦机制共享一部分数据。这允许创建一个高层级的视图,整合了来自多个源的监控数据,以便进行全面的分析和报告。
      • 可扩展性和灵活性:联邦允许监控系统以可扩展和灵活的方式成长。可以根据需要添加更多的Prometheus实例来监控新的服务或基础设施部分,而不会影响到现有的监控设置或需要重建整个监控架构。
      • 减轻中心实例的负担:通过只从各个自治实例中汇总必要的数据,中心Prometheus实例的资源负担可以得到显著减轻。这使得中心实例可以更有效地处理数据,提供全局视图,而不必处理每个指标的全部细节。

      使用场景

      Prometheus联邦的典型使用场景包括:

      • 多层监控架构:在大型或复杂环境中,顶层Prometheus实例可以用于聚合和查看关键业务指标,而更底层的实例则负责监控具体的服务或基础设施组件。
      • 跨区域或跨数据中心监控:在地理上分散的环境中,每个位置可以有自己的Prometheus实例,而一个联邦实例则负责聚合这些数据,提供一个统一的监控视图。
      • 性能和可用性优化:联邦可以帮助优化性能和可用性,通过分散查询负载和降低单个实例的数据保留需求。

      总之,Prometheus的联邦机制体现了一种旨在结合自治和共享的平衡方式,通过分散和集中的结合来实现更有效、更灵活的监控策略。

    3. Get metrics outside of prometheus

      要实现这个目标,你可以通过几种方法来配置Kubernetes中的Prometheus,使其能够监控集群外的on-premise services。以下是一些建议的解决方案:

      1. 使用Federation

      Prometheus支持使用联邦(Federation)功能来从其他Prometheus服务器中汇聚数据。你可以配置Kubernetes集群中的Prometheus实例作为一个联邦父节点,从集群外的on-premise Prometheus实例中抓取metrics。这种方法允许你从多个Prometheus实例中选择性地聚合数据。

      1. 在集群外的Prometheus配置中,确保它的metrics对外是可访问的,设置适当的权限和防火墙规则。
      2. 在Kubernetes集群的Prometheus配置中,添加一个新的scrape配置,指向集群外Prometheus的/federate端点,并使用match[]参数指定要抓取的metrics集。

      2. 直接抓取on-premise服务的metrics

      如果on-premise服务的metrics端点是对外可访问的,并且与Kubernetes集群的Prometheus网络可达,你可以直接在Kubernetes集群的Prometheus配置中添加静态targets来抓取这些服务的metrics。

      1. 在Kubernetes集群的Prometheus的配置文件(通常是prometheus.yaml),添加一个新的scrape job。
      2. 在这个job中,使用静态配置指定on-premise服务的地址和端口,类似于你在on-premise Prometheus中所做的。

      3. 使用Prometheus PushGateway

      如果直接抓取on-premise服务的metrics存在网络隔离或安全策略的问题,可以考虑使用Prometheus PushGateway。on-premise服务可以定期将metrics推送到PushGateway,而Kubernetes集群中的Prometheus则可以从PushGateway抓取这些metrics。

      1. 部署Prometheus PushGateway在一个对两个环境都可访问的位置。
      2. 配置on-premise服务将metrics推送到PushGateway。
      3. 在Kubernetes集群的Prometheus配置中,添加一个新的scrape job来抓取PushGateway的metrics。

      选择最佳方案

      选择哪种方法取决于多个因素,包括网络配置、安全需求、以及是否愿意维护额外的组件(如PushGateway)。如果可能,使用Federation或直接抓取on-premise服务的metrics通常更简单直接,因为这两种方法不需要维护额外的中间件。但是,如果网络或安全策略限制了这两种方法的使用,那么使用PushGateway可能是一个可行的解决方案。

    4. 在Prometheus的上下文中,当配置scrape jobs以收集来自不同服务的metrics时,安全性变得至关重要,尤其是当这些服务部署在不受信任的网络或者需要确保数据传输安全和访问控制时。Prometheus支持几种认证和加密机制来保证数据的安全传输和访问控制,包括基本认证、Bearer Token认证和通过TLS进行传输加密。下面是对这些机制的简要解释:

      基本认证(Basic Authentication)

      基本认证是HTTP协议支持的一种简单的认证方式,它允许HTTP用户代理(如Prometheus服务器)通过请求头中的Authorization字段提供用户名和密码。这种方式不需要复杂的请求编码或会话管理,但因为用户名和密码是以明文形式发送的(虽然是Base64编码,但容易被解码),所以只有在HTTPS等加密通道中使用时才安全。

      在Prometheus配置中,可以为特定的scrape job配置基本认证,示例如下:

      yaml scrape_configs: - job_name: 'my-secure-service' scheme: https # 确保使用https static_configs: - targets: ['secure-service.example.com:443'] basic_auth: username: 'myUsername' password: 'myPassword'

      Bearer Token认证

      Bearer Token认证是一种更安全的HTTP认证方法,通常用于OAuth 2.0等认证框架。在这种方法中,客户端发送一个Authorization请求头,包含一个安全令牌,这个令牌代表客户端的认证凭据。

      在Prometheus的场景中,Bearer Token可以用于访问需要OAuth2.0或类似机制保护的服务。配置示例如下:

      yaml scrape_configs: - job_name: 'my-oauth2-service' scheme: https # 使用https static_configs: - targets: ['oauth2-service.example.com:443'] authorization: type: 'Bearer' credentials: 'mySecretToken'

      TLS配置

      传输层安全(TLS)是一种加密协议,旨在提供计算机网络通信的安全和数据完整性保护。Prometheus支持通过TLS连接到目标服务,这样可以确保抓取过程中的数据加密和安全传输。

      配置TLS,你需要指定TLS证书和密钥,有时还需要CA证书来验证服务器的证书。这在访问使用自签名证书的服务或在强制加密环境下特别有用。TLS配置示例:

      yaml scrape_configs: - job_name: 'my-tls-service' scheme: https # 使用https static_configs: - targets: ['tls-service.example.com:443'] tls_config: ca_file: '/path/to/ca.crt' # CA证书,用于验证服务器证书 cert_file: '/path/to/client.crt' # 客户端证书 key_file: '/path/to/client.key' # 客户端密钥 # 如果服务使用的是自签名证书,则需要设置下面这个选项 insecure_skip_verify: false

      使用这些机制,你可以确保Prometheus与你的服务之间的通信既安全又受控,保护敏感的metrics数据不被未授权访问或泄露。

    5. 在Prometheus中,"scrape job"是指定定时抓取(或称为"scraping")目标服务metrics的配置单元。每个scrape job定义了一组目标(targets),这些目标是Prometheus需要定期访问并收集metrics数据的服务或实例。scrape job的配置包括抓取频率、目标服务的地址、认证信息(如果需要的话)以及其他抓取行为的配置细节。

      核心组成

      • Job Name:每个scrape job都有一个唯一的名称,这个名称在Prometheus的metrics中用作job标签的值,用于区分来自不同scrape jobs的数据。
      • Targets:这些是Prometheus将要抓取metrics的具体服务实例。目标可以是静态配置的,也可以是通过服务发现动态发现的。
      • Scrape Interval:定义了Prometheus抓取每个目标metrics的频率。例如,scrape_interval: 15s意味着Prometheus每15秒向每个目标发送一次抓取请求。
      • Metrics Path:指定了目标服务暴露metrics的HTTP路径,默认值是/metrics
      • Scrape Timeout:指定了等待抓取请求返回的最长时间。如果超过这个时间目标还没有响应,抓取请求就会被取消。
      • Authentication and Authorization:如果目标服务需要认证,可以在scrape job配置中指定必要的认证信息,如基本认证、Bearer token或TLS配置。

      示例配置

      下面是一个简单的scrape job配置示例,它定义了一个名为my-service的scrape job,用于抓取运行在localhost:9090上的服务的metrics。

      yaml scrape_configs: - job_name: 'my-service' scrape_interval: '15s' static_configs: - targets: ['localhost:9090']

      动态服务发现

      Prometheus支持多种服务发现机制来动态发现scrape targets,比如Kubernetes、Consul、AWS EC2等。使用服务发现,Prometheus可以自动更新它的目标列表,以匹配动态变化的环境,例如在Kubernetes集群中自动发现和抓取新部署的服务。

      作用和重要性

      Scrape jobs是Prometheus监控配置的核心。它们确保Prometheus能够定期从配置的服务中收集metrics,从而提供系统和应用性能的实时视图。合理配置scrape jobs对于确保数据的准确性和时效性至关重要。

    6. Prometheus Federation 是一种机制,允许一个Prometheus服务器从另一个Prometheus服务器中抓取选定的数据。这种方法经常用于创建层次化的监控架构,其中高层级的Prometheus实例聚合和监控来自多个源的数据,而这些源可能是其他Prometheus实例。Federation特别适用于大规模环境、多层监控策略,或者当需要跨不同网络区域汇总监控数据时。

      Federation的工作原理

      在Federation设置中,有两个关键组件:父Prometheus实例(Federator)和子Prometheus实例。父实例负责抓取(scrape)来自一个或多个子实例的数据。这个过程是通过子实例上的/federate端点完成的。

      配置Federation

      要通过Federation抓取metrics,你需要在父Prometheus实例上配置一个新的scrape job,专门用于抓取来自子Prometheus实例的数据。这个配置可以指定要从子实例抓取哪些metrics,使用match[]参数来过滤。

      示例配置

      假设你想从一个on-premise Prometheus实例抓取特定的metrics到Kubernetes集群中的Prometheus实例。你可以在Kubernetes Prometheus的配置文件中添加类似以下的配置:

      yaml scrape_configs: - job_name: 'federate' scrape_interval: '15s' honor_labels: true metrics_path: '/federate' params: 'match[]': - '{job="prometheus"}' - '{__name__=~"job:.*"}' static_configs: - targets: - 'on-premise-prometheus.example.com:9090'

      在这个示例中:

      • job_name:这个scrape job的名称。
      • scrape_interval:抓取数据的频率。
      • honor_labels:设置为true,意味着Prometheus将保留从源Prometheus实例获取的metrics的标签,避免标签冲突。
      • metrics_path:指向子实例的/federate端点。
      • params:定义了一个match[]列表,用于指定哪些metrics应该被抓取。在这个例子中,它匹配所有标签为job="prometheus"的metrics,以及所有名称与job:.*正则表达式匹配的metrics。
      • static_configs:定义了子Prometheus实例的地址。

      使用Federation的优势和考虑

      优势:

      • 可扩展性:Federation允许构建可扩展的监控架构,通过在不同层次上聚合数据来管理大量的监控指标。
      • 灵活性:可以非常精细地控制哪些metrics被上层Prometheus实例抓取,允许构建定制的监控视图或汇总。

      需要考虑的因素:

      • 性能:抓取大量metrics可能会对网络和Prometheus实例的性能产生影响。合理配置scrape_interval和选择要抓取的metrics非常重要。
      • 安全性:确保网络通信安全,特别是在跨网络边界进行Federation时,需要考虑加密和认证机制。

      Federation提供了一种强大的方式来集中管理和聚合来自多个Prometheus实例的监控数据,但它也需要仔细的规划和配置以确保有效和高效地使用。

    1. Prometheus Architecture

      • the main Prometheus server which scrapes and stores time series data
      • client libraries for instrumenting application code
      • a push gateway for supporting short-lived jobs
      • special-purpose exporters for services like HAProxy, StatsD, Graphite, etc.
      • an alertmanager to handle alerts
      • various support tools
  2. Feb 2023
    1. Hesiod’s depictionof humans in the myth of Prometheus and Pandora. We consider theimplications of this myth for the Greek view of society and particularly of

      women and gender roles.

      If my perception of mythology and orality is correct, can we look at Indigenous stories, myth, and knowledge and draw parallels from their knowledge about women and gender to similar stories in the Western canon which have lost linkage to their narratives? What would this show us potentially about Western mythology and gender studies?

  3. Jan 2023
    1. tl;dw (best DevOps tools in 2023)

      1. Low-budget cloud computing : Civo (close to Scaleway)
      2. Infrastructure and Service Management: Crossplane
      3. App Management - manifests : cdk8s (yes, not Kustomize or Helm)
      4. App Management - k8s operators: tie between Knative and Crossplane
      5. App Management - managed services: Google Cloud Run
      6. Dev Envs: Okteto (yeap, not GitPod)
      7. CI/CD: GitHub Actions (as it's simplest to use)
      8. GitOps (CD): Argo CD (wins with Flux due to its adoption rate)
      9. Policy Management: Kyverno (simpler to use than industry's most powerful tool: OPA / Gatekeeper)
      10. Observability: OpenTelemetry (instrumentation of apps), VictoriaMetrics (metrics - yes not Prometheus), Grafana / Loki (logs), Grafana Tempo (tracing), Grafana (dashboards), Robusta (alerting), Komodor (troubleshooting)
  4. Dec 2021
    1. Support for exemplars is available for the Prometheus data source only

      the exemplar "feature" is not availble to all data sources.

  5. Mar 2021
    1. We use Prometheus to collect time-series metrics and Grafana for graphs, dashboards, and alerts.

      How Prometheus and Grafana can be used to collect information from running ML on K8s

  6. Dec 2019
    1. THE MODERN PROMETHEUS

      The novel’s subtitle invokes the trickster hero of Greek mythology, Prometheus, who defies the Gods by stealing fire (a symbol of knowledge) and giving it to humanity. Akin to Victor Frankenstein, Prometheus is also credited with the creation of man, which he fashions out of clay. As punishment for the disobedience, Zeus condemns Prometheus to eternal torment: he is chained to a rock for eternity while an eagle feeds on his liver. Shelley’s husband Percy would later take up the Prometheus myth in the closet drama Prometheus Unbound, published in 1819. Reading the novel against the myth, we can understand Prometheus’s punishment for the Gods akin to Victor’s psychological torment for defying nature.

  7. Mar 2019
    1. Grafana

      Parte do 1.o assunto no tópico 705 Service Operations: 705.1 IT Operations and Monitoring (weight: 4)

      Understand the architecture of Prometheus, including Exporters, Pushgateway, Alertmanager and Grafana

      Mais informações também nesse post de nosso blog.

    2. Prometheus

      Parte do 1.o assunto no tópico 705 Service Operations: 705.1 IT Operations and Monitoring (weight: 4)

      Understand the architecture of Prometheus, including Exporters, Pushgateway, Alertmanager and Grafana

      Mais informações também nesse post de nosso blog.

  8. Aug 2018
    1. for when they list into the womb That bred them they return, and howle and gnaw My Bowels, thir repast;

      This sounds similar toPrometheus, who was punished by Zeus for giving fire to man. Prometheus was bound in Tartarus, where a vulture every day gnawed out his liver.

  9. Jun 2017
    1. public void increment(String label, String topic) { + Stats.incr(label); + }

      import io.prometheus.client.Counter; public static final Counter requests = Counter.build() .name("requests_total").help("Total requests.").register();

      public void increment(String label, String topic) { requests.inc(); // Your code here. } }

    2. The component is pluggable, you can configure ingestion of metrics to any monitoring system by implementing MetricCollector interface. By default metrics are sent to Ostrich, statistic library bundled into secor.

      Just inject prometheus simple client into this module and you could get prometheus working for secor.

  10. Jul 2016