<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Prometheus 查詢語言 PromQL 使用說明 目前很多云原生應用使用了 Prometheus 作為監控,例如在 [Istio 中查詢 Prometheus 指標](https://istio.io/zh/docs/tasks/telemetry/querying-metrics/)。 Prometheus 提供了一種功能表達式語言,允許用戶實時選擇和匯總時間序列數據。表達式的結果可以顯示為圖形、表格數據或者由外部系統通過 [RESTful API](https://prometheus.io/docs/prometheus/latest/querying/api/) 消費。 ## 表達式語言數據類型 Prometheus 查詢語言簡稱 PromQL,其中包含以下四類數據類型: - **Instant vector(即時向量)**:一組時間序列,擁有共同的時間戳,每個時間序列中都包含一個樣本。 - **Range vector(范圍向量)**:一組時間序列,其中每個時間序列都包含一系列時間范圍內的數據點。 - **Scalar(標量)**:一個簡單的浮點值。 - **String(字符串)**:一個簡單的字符串,目前暫未使用。 ## 示例 可以通過 Prometheus web 頁面查詢。 ![Prometheus 的查詢頁面](https://ws2.sinaimg.cn/large/006tNbRwly1fwcl7v28rhj30xl0onadv.jpg) 還可以使用 HTTP API 直接請求查詢,例如你使用 [kubernetes-vagrant-centos-cluster](https://github.com/rootsongjc/kubernetes-vagrant-centos-cluster) 部署了 [Istio](https://istio.io/zh),會默認安裝 Prometheus,你可以在瀏覽器中請求 <http://prometheus.istio.jimmysong.io/api/v1/query?query=http_requests_total{job=%22kubernetes-nodes%22}>,將會看到如下格式的 json 返回值。 ```json { "status": "success", "data": { "resultType": "vector", "result": [ { "metric": { "__name__": "http_requests_total", "beta_kubernetes_io_arch": "amd64", "beta_kubernetes_io_os": "linux", "code": "200", "handler": "prometheus", "instance": "node1", "job": "kubernetes-nodes", "kubernetes_io_hostname": "node1", "method": "get" }, "value": [ 1539861026.814, "556" ] }, { "metric": { "__name__": "http_requests_total", "beta_kubernetes_io_arch": "amd64", "beta_kubernetes_io_os": "linux", "code": "200", "handler": "prometheus", "instance": "node2", "job": "kubernetes-nodes", "kubernetes_io_hostname": "node2", "method": "get" }, "value": [ 1539861026.814, "555" ] }, { "metric": { "__name__": "http_requests_total", "beta_kubernetes_io_arch": "amd64", "beta_kubernetes_io_os": "linux", "code": "200", "handler": "prometheus", "instance": "node3", "job": "kubernetes-nodes", "kubernetes_io_hostname": "node3", "method": "get" }, "value": [ 1539861026.814, "556" ] } ] } } ``` **HTTP API 說明** 上面是對最常用也是比較簡單的即時查詢,下面是對以上返回結果的簡要說明。 - `status`:可以為 `success` 和 `error`, 如果為 `error`,則不會顯示 `data` 字段,而顯示 `errorType` 和 `error`。 - `resultType`:返回結果類型,可以為 `matrix`、`vector`、`scalar` 或 `string`。 - `metric`:即時查詢的到的監控 metric,其中的項為 label,可以在查詢 URL 中增加標簽選擇器來過濾 metric。 - `value` :第一個數字是 UNIX 格式的時間戳,例如 `1539861026.814` 表示的是北京時間 `2018/10/18 19:10:26.814`(注意:小數點后毫秒數)。Prometheus 中的 metric 時間都是以 UTC(協調世界時間)為單位的,無法調整時區,需要在前端展示時自己來調整。 您也可以查詢一個時間段、根據標簽選擇一組 metric、Prometheus 中的 target、rule、metadata 等配置進行查詢。關于 Prometheus RESTful API 的詳細用法請參考 [HTTP API](https://prometheus.io/docs/prometheus/latest/querying/api/)。 ## 參考 - [QUERYING PROMETHEUS - prometheus.io](https://prometheus.io/docs/prometheus/latest/querying/basics/) - [Setting up a distributed Kubernetes cluster along with Istio service mesh locally with Vagrant and VirtualBox - github.com](https://github.com/rootsongjc/kubernetes-vagrant-centos-cluster)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看