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. 2.Getting Started with Prometheus

Using the Expression Browser

PreviousRunning PrometheusNextRunning the Node Exporter

Last updated 6 years ago

Was this helpful?

表达式浏览器对于运行的时候查询,开发PromQL表达式以及调试PromQL和Prometheus中的数据非常有用

进入下图的页面输入up后点击Execute 可以看到一个名为up{instance="localhost:9090",job="prometheus"} 的结果和值。up这个是prometheus表示scrape成功后才会添加的指标,值为1则表示成功。这个结果是prometheus去scrape自己的指标。

此处的job这个标签来自prometheus.yml中的定义的job_name。 prometheus并不知道它正在刮一个prometheus,因此它应该使用一个值prometheus的job标签。 相反,这是一种需要用户进行配置的约定。 作业标签指示应用程序的类型。 接下来,您应该评估process_resident_memory_bytes,如图所示

我的prometheus正在使用大约44 MB的内存。 您可能想知道为什么使用字节而不是兆字节或千兆字节来公开此度量标准,这可能更具可读性。 答案是,更具可读性的内容在很大程度上取决于上下文,即使不同环境中的相同二进制文件也可能具有不同数量级的值。 内部RPC可能需要几微秒,而轮询长时间运行的进程可能需要数小时甚至数天。 因此,普罗米修斯的惯例是使用基本单位,如字节和秒,让图标程序去展示例如grafana

了解当前的内存使用情况非常好,但最重要的是看看它是如何随着时间的推移而发生变化的。 为此,请单击Graph切换到图形视图

像processresident_memory_bytes这样的度量标准称为Gauges。 对于Gauges,它的当前绝对值对您来说很重要。 还有第二种核心类型的指标叫counter。 计数器跟踪发生的事件数量或所有事件的总大小。 让我们通过绘制prometheus_tsdb_head samples_appended_total来看一个计数器,这是Prometheus摄入的样本数量,如图

计数器(counter)总是在增加。 这会产生美观和正确的图形,但计数器的值本身并没有多大用处。 你真正想知道的是计数器增加的速度,这是rate函数的来源。rate函数计算计数器每秒增加的速度。 调整你的 rate(prometheus_tsdb_head_samples_appended_total[1m]),它将计算普罗米修斯每分钟在一分钟内平均摄取的样本数量,并产生如图的结果

你现在可以看到普罗米修斯平均每秒摄取68个左右的样本。 由于进程重新启动且样本未完全对齐,速率函数会自动处理计数器重置