wxrdnx
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
--- title: Prometheus Overview tags: Prometheus, Monitoring slideOptions: theme: night transition: 'fade' --- <style type="text/css"> .reveal p { font-size: 28px; text-align: left; } .reveal ul { font-size: 28px; display: block; } .reveal ol { font-size: 28px; display: block; } .reveal h1 { font-size: 80px; display: block; } .reveal h1 { font-size: 72px; display: block; } .reveal h2 { font-size: 64px; display: block; } .reveal h3 { font-size: 56px; display: block; } .reveal h4 { font-size: 48px; display: block; } .reveal h5 { font-size: 40px; display: block; } .reveal h6 { font-size: 32px; display: block; } </style> ## <b style="color:darkgrey;text-align:center">Prometheus Overview</b> #### <b style="color:lightgrey;text-align:center"> B06902031 資工四 何承勳</b> --- ## <b style="color:darkgrey">Outline</b> <font color=gray> - Introduction - Architecture - Components - Prometheus Server - Exporters - Push Gateway - Alertmanager - Consoles and Dashboards - Service Discovery - Pros and Cons </font> --- ## <b style="color:darkgrey">Outline</b> <font color=gray> - <b style="color: orange">Introduction</b> - Architecture - Components - Prometheus Server - Exporters - Push Gateway - Alertmanager - Consoles and Dashboards - Service Discovery - Pros and Cons </font> ---- ## <b style="color: orange;">Introduction</b> - Prometheus is an pen-source systems monitoring and alerting toolkit. It is written in <b style="color: deepskyblue">Go</b>, licensed under the <b style="color: deepskyblue"> Apache 2 License</b> - Prometheus collects metrics from configured targets at given intervals, and store the time series data in its database. - Prometheus runs rules over the collected data to aggregate these data or generate alerts. - Several dashboards are available for administrator to visualize the collected data. ---- ## <b style="color: orange;">Features</b> - Prometheus stores all data as time series, which can be identified by <b style="color: deepskyblue">metric names</b>. - Prometheus provides a query language called <b style="color: deepskyblue">PromQL</b> that allows the user to query and aggregate time series data. - Prometheus collects data via <b style="color: deepskyblue">HTTP PULL method</b>. Alternatively, pushing mechanism is supported through <b style="color: deepskyblue">push gateway</b>. - Prometheus can trigger alerts if certain condition is observed to be true. --- ## <b style="color:darkgrey">Outline</b> <font color=gray> - Introduction - <b style="color: orange;">Architecture</b> - Components - Prometheus Server - Exporters - Push Gateway - Alertmanager - Consoles and Dashboards - Service Discovery - Pros and Cons </font> ---- ![](https://i.imgur.com/ofZL4UR.png) --- ## <b style="color:darkgrey">Outline</b> <font color=gray> - Introduction - Architecture - <b style="color: orange;">Components</b> - Prometheus Server - Exporters - Push Gateway - Alertmanager - Consoles and Dashboards - Service Discovery </font> --- ## <b style="color:darkgrey">Outline</b> <font color=gray> - Introduction - Architecture - Components - <b style="color: orange;">Prometheus Server</b> - Exporters - Push Gateway - Alertmanager - Consoles and Dashboards - Service Discovery - Pros and Cons </font> ---- ## <b style="color: orange;">Prometheus Server</b> - The Prometheus Server retrieves data from monitored target, stores time series data into the database, and provide interface for users to query the database. - Generically, consists of three components: - <b style="color: deepskyblue">Time Series Database (TSDB)</b> - <b style="color: deepskyblue">HTTP Server</b> - <b style="color: deepskyblue">Prometheus Quering Language (PromQL)</b> ---- ## <b style="color: orange">TSDB</b> - Prometheus server consists of a Time Series database (TSDB). A <b style="color: deepskyblue">TSDB</b> is a database optimized for handling time series data. - Prometheus stores all data by time series. Every time series is uniquely identified by its <b style="color: deepskyblue">metric name</b> and optional key-value pairs called <b style="color: deepskyblue">labels</b>. ---- ### <b style="color: orange">Metrics</b> - For example, a time series with the metric name <span style="color:limegreen;font-family:monospace">prometheus_http_requests_total</span> (which indicates the number of accumulated http requests to Prometheus Server), and the labels <span style="color:limegreen;font-family:monospace">method="POST"</span> (which specifies the number of POST requests) could be written like the following: ``` prometheus_http_requests_total{method="POST", handler="/messages"} ``` ---- ### <b style="color: orange">Metrics</b> - Metrics can be categorized into four types: 1. <b style="color: deepskyblue">Counter</b>: Metrics that can be accumulated, such as the number of occurrences of an HTTP Get requests. 2. <b style="color: deepskyblue">Gauge</b>: Any change metric that is instantaneous and independent of time, such as memory usage. 3. <b style="color: deepskyblue">Histogram</b>: Mainly used to represent data sampling within a period of time. 4. <b style="color: deepskyblue">Summary</b>: Similar to Histogram, it is used to represent the summary of data sampling in a time range. ---- ### <b style="color: orange">PromQL</b> - <b style="color:deepskyblue">PromQL</b> (Prometheus Query Language) is a quering language provided by Prometheus that allows the user to select, examine, and aggregate time series data. - [Official Documentation of PromQL](https://prometheus.io/docs/prometheus/latest/querying/examples/) ---- ### <b style="color: orange">HTTP Server</b> - Prometheus server provides a <b style="color:deepskyblue">HTTP API</b> for users to query the database. - The current stable HTTP API is reachable under <span style="color:limegreen;font-family:monospace">/api/v1</span> on a Prometheus server. - The API response format is in <b style="color:deepskyblue">JSON</b>. ---- ### <b style="color: orange">HTTP Server</b> - Example: We can use curl to query the Prometheus server: ```bash curl 'http://localhost:9090/api/v1/query?query=up ``` - The Prometheus server will then return the result in JSON format: ```json { "status" : "success", "data" : { "resultType" : "vector", "result" : [ { "metric" : { "__name__" : "up", "job" : "prometheus", "instance" : "localhost:9090" }, "value": [ 1435781451.781, "1" ] }, ] } } ``` --- ## <b style="color:darkgrey">Outline</b> <font color=gray> - Introduction - Architecture - Components - Prometheus Server - <b style="color: orange;">Exporters</b> - Push Gateway - Alertmanager - Consoles and Dashboards - Service Discovery - Pros and Cons </font> ---- ## <b style="color: orange">Exporters</b> - <b style="color:deepskyblue">Exporters</b> are used to expose metrics of third-party services to Prometheus Server. The Exporters are installed on the monitored device. - Exporters will expose an <b style="color:deepskyblue">http endpoint</b> for Prometheus server to retrieve metrics. Prometheus mainly uses <b style="color:deepskyblue">HTTP PULL</b> method to collect metrices. It retrieves metrics by periodically pulling metrics from the monitored target's http endpoints. - Exporters is written using <b style="color:deepskyblue">Prometheus Client Libraries</b>. The library supports many differnt languages. The client library provides an API that can sends the metrics back to the server when Prometheus scrapes the target's HTTP endpoint. ---- ### <b style="color: orange">Exporter</b> - <b style="color:deepskyblue">Node exporter</b> is one of the most common official exporter. It exposes some hardware and OS metrics of UNIX kernels. For example: CPU usage, memory statics, disk I/O statistics, network statistics, and so on. ([Node Exporter Github Page](https://github.com/prometheus/node_exporter)) - <b style="color:deepskyblue">Mysql server exporter</b> is another common official exporter. It allows us to monitor, measure database performance, examine resource utilization, and so on. ([MySQL Exporter Github Page](https://github.com/prometheus/mysqld_exporter)) - If no existing exporters meet our need, we can write our own exporter using <b style="color:deepskyblue">Prometheus Client Libraries</b>. --- ## <b style="color:darkgrey">Outline</b> <font color=gray> - Introduction - Architecture - Components - Prometheus Server - Exporters - <b style="color: orange;">Push Gateway</b> - Alertmanager - Consoles and Dashboards - Service Discovery - Pros and Cons </font> ---- ### <b style="color: orange">Pushgateway</b> - Occasionally, we might need to monitor components which cannot be scraped. In this case, the <b style="color:deepskyblue">Pushgateway</b> is used to tackle the problem. These metrices will be pushed onto the Pushgateway first, then Prometheus will periodically pull the metrics from the Pushgateway. - In the official documentation, it states that "*Usually, the only valid use case for the Pushgateway is for capturing the outcome of a service-level batch job*". An example of "service-level" batch job is deleting a number of users for an entire service. is a discrete job which is not related to a specific machine. - In conclusion, the Pushgateway is seldomly used. --- ## <b style="color:darkgrey">Outline</b> <font color=gray> - Introduction - Architecture - Components - Prometheus Server - Exporters - Push Gateway - <b style="color: orange;">Alertmanager</b> - Consoles and Dashboards - Service Discovery - Pros and Cons </font> ---- ### <b style="color: orange">Alert Manager</b> - By defining alarm rule in Prometheus' configuration file, Prometheus will periodically calculate the alarm rule. If it meets the alarm trigger conditions, it will push an alarm to the <b style="color: deepskyblue;">Alertmanager</b>. - The Alertmanager can further inform the administrator some abnormal events via email, Pagerduty, etc. --- ## <b style="color:darkgrey">Outline</b> <font color=gray> - Introduction - Architecture - Components - Prometheus Server - Exporters - Push Gateway - Alertmanager - <b style="color: orange;">Consoles and Dashboards</b> - Service Discovery - Pros and Cons </font> ---- ### <b style="color: orange">Expression Browser</b> - The expression browser is available at <span style="color:limegreen;font-family:monospace">/graph</span> on the Prometheus server. It allowing us to enter any PromQL query and see its result in a table or a graph. ---- ### <b style="color: orange">Grafana</b> - <b style="color: deepskyblue">Grafana</b> is a universal visualization tool suitable for visualizing and displaying data stored in different databases including Prometheus. ---- ### <b style="color: orange">Console Template</b> - Prometheus consists of a simple built-in console template that allows users to create any console interface. - [Official documentation of Prometheus Console Template](https://prometheus.io/docs/visualization/consoles/) --- ## <b style="color:darkgrey">Outline</b> <font color=gray> - Introduction - Architecture - Components - Prometheus Server - Exporters - Push Gateway - Alertmanager - Consoles and Dashboards - <b style="color: orange;">Service Discovery</b> - Pros and Cons ---- ### <b style="color: orange">Service Discovery</b> - In cloud environment, there is no fixed monitoring target, and nearly every monitored object in the cloud changes dynamically. Thus, we cannot statically monitor every device in the cloud. - The solution to the above problem is introducing an intermediate agent. This agent has access to all current monitored targets. - Prometheus only needs to ask the agent what monitoring targets there are. Such mechanism is called <b style="color: deepskyblue;">service discovery</b>. ---- ### <b style="color: orange">Example</b> - In some cloud environments like <b style="color: deepskyblue">AWS</b>, Prometheus has the ability to find all cloud hosts that need to be monitored by using the API provided by the platform. - In <b style="color: deepskyblue">Kubernetes</b>, The master node manages all nodes information, Thus, Prometheus only need to interact with the master node to find all the containers and service objects that need to be monitored. --- - Introduction - Architecture - Components - Prometheus Server - Exporters - Push Gateway - Alertmanager - Consoles and Dashboards - Service Discovery - <b style="color: orange;">Pros and Cons</b> ---- ### <b style="color: orange">Pros</b> - Prometheus is mainly used for event monitoring and event alerting. It works prticularly well for recording purely time series data. - Prometheus fits well in monitoring dynamic service-oriented cloud environments such as Kubernetes. - Prometheus has higher reliability since Prometheus server is a standalone monitoring system, ane it does not depending on network storage or other remote services. ---- ### <b style="color: orange">Cons</b> - Prometheus does not offer durable long-term storage. The data storage of Prometheus is ephemeral since is mainly used for event monitoring and alerting. - Prometheus does not support logging. Prometheus is designed to collect and process metrics, not an event logging system. ---- ### <b style="color: orange">Concusion</b> - In our project, Elastic Stack can be used to perform long-term data storage, monitoring, and data retrieval, while Prometheus can be used to perform short-term event monitoring and alerting. - Since Prometheus works well in monitoring cloud enviroment, it can be deployed into our Kubernetes and perform monitoring on the entire opKubernetes.

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully