Prometheus Up & Running
  • Introduction
  • PART I -- Introduction
    • 1.What Is Prometheus?
      • What Is Monitoring?
        • A Brief and Incomplete History of Monitoring
        • Categories of Monitoring
      • Prometheus Architecture
        • Client Libraries
        • Exporters
        • Service Discovery
        • Scraping
        • Storage
        • Dashboards
        • Recording Rules and Alerts
        • Alert Management
        • Long-Term Storage
      • What Prometheus Is Not
    • 2.Getting Started with Prometheus
      • Running Prometheus
      • Using the Expression Browser
      • Running the Node Exporter
      • Alerting
  • Part II. Application Monitoring(建议直接跳至5.Labels)
    • 3.Instrumentation
      • A Simple Program
      • The Counter
        • Counting Exceptions
        • Counting Size
      • The Gauge
        • Using Gauges
        • Callbacks
      • The Summary
      • The Histogram
        • Buckets
      • Unit Testing Instrumentation
      • Approaching Instrumentation
        • What Should I Instrument?
        • How Much Should I Instrument?
        • What Should I Name My Metrics?
    • 4. Exposition
      • Python
        • WSGI
        • Twisted
        • Multiprocess with Gunicorn
      • Go
      • Java
        • HTTPServer
        • Servlet
      • Pushgateway
      • Bridges
      • Parsers
      • Exposition Format
        • Metric Types
        • Labels
        • Escaping
        • Timestamps
        • check metrics
    • 5. Labels
      • What Are Labels?
      • Instrumentation and Target Labels
      • Instrumentation
        • Metric
        • Multiple Labels
        • Child
      • Aggregating
      • Label Patterns
        • Enum
        • Info
      • When to Use Labels
        • Cardinality
    • 6. Dashboarding with Grafana
      • Installation
      • Data Source
      • Dashboards and Panels
        • Avoiding the Wall of Graphs
      • Graph Panel
        • Time Controls
      • Singlestat Panel
      • Table Panel
      • Template Variables
  • Part III. Infrastructure Monitoring
    • 7.Node Exporter
      • CPU Collector
      • Filesystem Collector
      • Diskstats Collector
      • Netdev Collector
      • Meminfo Collector
      • Hwmon Collector
      • Stat Collector
      • Uname Collector
      • Loadavg Collector
      • Textfile Collector
        • Using the Textfile Collector
        • Timestamps
    • 8.Service Discovery
      • Service Discovery Mechanisms
        • Static
        • File
        • Consul
        • EC2
      • Relabelling
        • Choosing What to Scrape
        • Target Labels
      • How to Scrape
        • metric_relabel_configs
        • Label Clashes and honor_labels
    • 9.Containers and Kubernetes
      • cAdvisor
        • CPU
        • Memory
        • Labels
      • Kubernetes
        • Running in Kubernetes
        • Service Discovery
        • kube-state-metrics
    • 10.Common Exporters
      • Consul
      • HAProxy
      • Grok Exporter
      • Blackbox
        • ICMP
        • TCP
        • HTTP
        • DNS
        • Prometheus Configuration
    • 11.Working with Other Monitoring Systems
      • Other Monitoring Systems
      • InfluxDB
      • StatsD
    • 12.Writing Exporters
      • Consul Telemetry
      • Custom Collectors
        • Labels
      • Guidelines
  • Part IV. PromQL
    • 13.Introduction to PromQL
      • Aggregation Basics
        • Gauge
        • Counter
        • Summary
        • Histogram
      • Selectors
        • Matchers
        • Instant Vector
        • Range Vector
        • Offset
      • HTTP API
        • query
        • query_range
    • 14.Aggregation Operators
      • Grouping
        • without
        • by
      • Operators
        • sum
        • count
        • avg
        • stddev and stdvar
        • min and max
        • topk and bottomk
        • quantile
        • count_values
    • 15.Binary Operators
      • Working with Scalars
        • Arithmetic Operators
        • Comparison Operators
      • Vector Matching
        • One-to-One
        • Many-to-One and group_left
        • Many-to-Many and Logical Operators
      • Operator Precedence
    • 16.Functions
      • Changing Type
        • vector
        • scalar
      • Math
        • abs
        • ln, log2, and log10
        • exp
        • sqrt
        • ceil and floor
        • round
        • clamp_max and clamp_min
      • Time and Date
        • time
        • minute, hour, day_of_week, day_of_month, days_in_month, month, and year
        • timestamp
      • Labels
        • label_replace
        • label_join
      • Missing Series and absent
      • Sorting with sort and sort_des
      • Histograms with histogram_quantile
      • Counters
        • rate
        • increase
        • irate
        • resets
      • Changing Gauges
        • changes
        • deriv
        • predict_linear
        • delta
        • idelta
        • holt_winters
      • Aggregation Over Time
    • 17.Recording Rules
      • Using Recording Rules
      • When to Use Recording Rules
        • Reducing Cardinality
        • Composing Range Vector Functions
        • Rules for APIs
        • How Not to Use Rules
      • Naming of Recording Rules
  • Part V. Alerting
    • 18.Alerting
      • Alerting Rules
        • for
        • Alert Labels
        • Annotations and Templates
        • What Are Good Alerts?
      • Configuring Alertmanagers
        • External Labels
    • 19.Alertmanager
      • Notification Pipeline
      • Configuration File
      • Alertmanager Web Interface
  • Part VI. Deployment
    • 20.Putting It All Together
      • Planning a Rollout
        • Growing Prometheus
      • Going Global with Federation
      • Long-Term Storage
      • Running Prometheus
        • Hardware
        • Configuration Management
        • Networks and Authentication
      • Planning for Failure
        • Alertmanager Clustering
        • Meta- and Cross-Monitoring
      • Managing Performance
        • Detecting a Problem
        • Finding Expensive Metrics and Targets
        • Reducing Load
        • Horizontal Sharding
      • Managing Change
      • Getting Help
Powered by GitBook
On this page

Was this helpful?

  1. PART I -- Introduction
  2. 1.What Is Prometheus?
  3. Prometheus Architecture

Client Libraries

度量标准(Metrics)通常不会从应用程序中神奇地出现; 必须有人添加产生它们的代码。 这是客户端库的用武之地。通常只有两到三行代码,您可以定义一个度量标准,并在您控制的代码中内嵌所需的检测。 这被称为direct instrumentation。 客户端库可用于所有主要语言和runtimes。 Prometheus项目提供Go,Python,Java / JVM和Ruby中的官方客户端库。 还有各种第三方客户端库,例如C#/.Net,Node.js,Haskell,Erlang和Rust。

官方和第三方 不要被非官方或第三方的集成所拖延。有许多您希望与之集成的应用程序和系统是Prometheus项目团队无法拥有创建和开发的时间和专业知识。因此,在这个生态中的绝大多数集成都是第三方。 为了使事情保持合理一致并按预期工作,可以阅读有关如何编写集成的指南

客户端库负责处理所有细节,例如线程安全,簿记以及生成Prometheus文本展示格式以响应HTTP请求。 由于基于度量的监视不跟踪单个事件,因此客户端库内存使用量不会增加您拥有的事件。 相反,内存与您拥有的指标数量有关 如果应用程序的某个库依赖项具有Prometheus检测,则会自动获取它。 因此,通过检测诸如RPC客户端之类的密钥库,您可以在所有应用程序中获取它的检测。 某些度量标准通常由客户端库提供,例如CPU使用率和垃圾回收统计信息,具体取决于库和运行时环境。 客户端库不限于以Prometheus文本格式输出指标。 Prometheus是一个开放的生态系统,用于提供生成文本格式的相同API可用于生成其他格式的度量标准或提供给其他仪器系统。 同样,如果您还没有完全将所有内容转换为Prometheus的客户端,则可以从其他仪器系统中获取指标并将其连接到Prometheus客户端库中。

PreviousPrometheus ArchitectureNextExporters

Last updated 6 years ago

Was this helpful?