当前位置: 首页 > 软件库 > 云计算 > 云原生 >

prometheus-operator

授权协议 Apache-2.0 License
开发语言 Google Go
所属分类 云计算、 云原生
软件类型 开源软件
地区 不详
投 递 者 单于翰飞
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Prometheus Operator

Build Status

Project status: beta Not all planned features are completed. The API, spec, status and other user facing objects may change, but in a backward compatible way.

Note: Project was previously known as coreos/prometheus-operator.

Overview

The Prometheus Operator provides Kubernetes native deployment and management ofPrometheus and related monitoring components. The purpose of this project is tosimplify and automate the configuration of a Prometheus based monitoring stack for Kubernetes clusters.

The Prometheus operator includes, but is not limited to, the following features:

  • Kubernetes Custom Resources: Use Kubernetes custom resources to deploy and manage Prometheus, Alertmanager,and related components.

  • Simplified Deployment Configuration: Configure the fundamentals of Prometheus like versions, persistence,retention policies, and replicas from a native Kubernetes resource.

  • Prometheus Target Configuration: Automatically generate monitoring target configurations basedon familiar Kubernetes label queries; no need to learn a Prometheus specific configuration language.

For an introduction to the Prometheus Operator, see the getting started guide.

Prometheus Operator vs. kube-prometheus vs. community helm chart

Prometheus Operator

The Prometheus Operator uses Kubernetes custom resources to simplify the deployment and configuration of Prometheus, Alertmanager, and related monitoring components.

kube-prometheus

kube-prometheus provides example configurations for a complete cluster monitoringstack based on Prometheus and the Prometheus Operator. This includes deployment of multiple Prometheus and Alertmanager instances,metrics exporters such as the node_exporter for gathering node metrics, scrape target configuration linking Prometheus to variousmetrics endpoints, and example alerting rules for notification of potential issues in the cluster.

helm chart

The prometheus-community/kube-prometheus-stackhelm chart provides a similar feature set to kube-prometheus. This chart is maintained by the Prometheus community.For more information, please see the chart's readme

Prerequisites

Version >=0.39.0 of the Prometheus Operator requires a Kubernetescluster of version >=1.16.0. If you are just starting out with thePrometheus Operator, it is highly recommended to use the latest version.

If you have an older version of Kubernetes and the Prometheus Operator running,we recommend upgrading Kubernetes first and then the Prometheus Operator.

CustomResourceDefinitions

A core feature of the Prometheus Operator is to monitor the Kubernetes API server for changesto specific objects and ensure that the current Prometheus deployments match these objects.The Operator acts on the following custom resource definitions (CRDs):

  • Prometheus, which defines a desired Prometheus deployment.

  • Alertmanager, which defines a desired Alertmanager deployment.

  • ThanosRuler, which defines a desired Thanos Ruler deployment.

  • ServiceMonitor, which declaratively specifies how groups of Kubernetes services should be monitored.The Operator automatically generates Prometheus scrape configuration based on the current state of the objects in the API server.

  • PodMonitor, which declaratively specifies how group of pods should be monitored.The Operator automatically generates Prometheus scrape configuration based on the current state of the objects in the API server.

  • Probe, which declaratively specifies how groupsof ingresses or static targets should be monitored. The Operator automatically generates Prometheus scrape configurationbased on the definition.

  • PrometheusRule, which defines a desired set of Prometheus alerting and/or recording rules.The Operator generates a rule file, which can be used by Prometheus instances.

  • AlertmanagerConfig, which declaratively specifies subsections of the Alertmanager configuration, allowingrouting of alerts to custom receivers, and setting inhibit rules.

The Prometheus operator automatically detects changes in the Kubernetes API server to any of the above objects, and ensures thatmatching deployments and configurations are kept in sync.

To learn more about the CRDs introduced by the Prometheus Operator have a lookat the design doc.

To automate validation of your CRD configuration files see about linting.

Dynamic Admission Control

To prevent invalid Prometheus alerting and recording rules from causing failures in a deployed Prometheus instance,an admission webhookis provided to validate PrometheusRule resources upon initial creation or update.

For more information on this feature, see the user guide.

Quickstart

Note: this quickstart does not provision an entire monitoring stack; if that is what you are looking for,see the kube-prometheus project. If you want the whole stack,but have already applied the bundle.yaml, delete the bundle first (kubectl delete -f bundle.yaml).

To quickly try out just the Prometheus Operator inside a cluster, choose a release and run the following command:

kubectl apply -f bundle.yaml

Note: make sure to adapt the namespace in the ClusterRoleBinding if deploying in a namespace other than the default namespace.

To run the Operator outside of a cluster:

make
scripts/run-external.sh <kubectl cluster name>

Removal

To remove the operator and Prometheus, first delete any custom resources you created in each namespace. Theoperator will automatically shut down and remove Prometheus and Alertmanager pods, and associated ConfigMaps.

for n in $(kubectl get namespaces -o jsonpath={..metadata.name}); do
  kubectl delete --all --namespace=$n prometheus,servicemonitor,podmonitor,alertmanager
done

After a couple of minutes you can go ahead and remove the operator itself.

kubectl delete -f bundle.yaml

The operator automatically creates services in each namespace where you created a Prometheus or Alertmanager resources,and defines three custom resource definitions. You can clean these up now.

for n in $(kubectl get namespaces -o jsonpath={..metadata.name}); do
  kubectl delete --ignore-not-found --namespace=$n service prometheus-operated alertmanager-operated
done

kubectl delete --ignore-not-found customresourcedefinitions \
  prometheuses.monitoring.coreos.com \
  servicemonitors.monitoring.coreos.com \
  podmonitors.monitoring.coreos.com \
  alertmanagers.monitoring.coreos.com \
  prometheusrules.monitoring.coreos.com

Development

Prerequisites

  • golang environment
  • docker (used for creating container images, etc.)
  • kind (optional)

Testing

Ensure that you're running tests in the following path:$GOPATH/src/github.com/prometheus-operator/prometheus-operator as tests expect paths tomatch. If you're working from a fork, just add the forked repo as a remote andpull against your local prometheus-operator checkout before running tests.

Running unit tests:

make test-unit

Running end-to-end tests on local kind cluster:

  1. kind create cluster --image=kindest/node:<latest>. e.g v1.16.2 version.
  2. kubectl cluster-info --context kind-kind. kind version >= 0.6.x
  3. make image - build Prometheus Operator docker image locally.
  4. for n in "operator" "config-reloader"; do kind load docker-image "quay.io/prometheus-operator/prometheus-$n:$(git rev-parse --short HEAD)"; done - publishbuilt locally images to be accessible inside kind.
  5. make test-e2e

Running end-to-end tests on local minikube cluster:

  1. minikube start --kubernetes-version=v1.10.0 --memory=4096 --extra-config=apiserver.authorization-mode=RBAC
  2. eval $(minikube docker-env) && make image - build Prometheus Operatordocker image on minikube's docker
  3. make test-e2e

Contributing

Many files (documentation, manifests, ...) in this repository areauto-generated. E.g. bundle.yaml originates from the Jsonnet files in/jsonnet/prometheus-operator. Before proposing a pull request:

  1. Commit your changes.
  2. Run make generate.
  3. Commit the generated changes.

Security

If you find a security vulnerability related to the Prometheus Operator, pleasedo not report it by opening a GitHub issue, but instead please send an e-mail tothe maintainers of the project found in the MAINTAINERS.md file.

Troubleshooting

Check the troubleshooting documentation forcommon issues and frequently asked questions (FAQ).

Acknowledgements

prometheus-operator organization logo was created and contributed by Bianca Cheng Costanzo.

 相关资料
  • Prometheus 是由 SoundCloud 开源监控告警解决方案,从 2012 年开始编写代码,再到 2015 年 GitHub 上开源以来,已经吸引了 9k+ 关注,以及很多大公司的使用;2016 年 Prometheus 成为继 Kubernetes 之后,成为 CNCF (Cloud Native Computing Foundation)中的第二个项目成员。 作为新一代开源解决方案,

  • Prometheus 是一个开源的服务监控系统和时间序列数据库。 特性: 高维度数据模型 自定义查询语言 可视化数据展示 高效的存储策略 易于运维 提供各种客户端开发库 警告和报警 数据导出

  • Prometheus监控 Canal server 性能指标监控基于prometheus的实现。 关于prometheus,参见 官网 效果示意图 Quick start 安装并部署对应平台的prometheus,参见官方guide 配置prometheus.yml,添加canal的job,示例: - job_name: 'canal' static_configs: - targets: [

  • prometheus作为优秀的开源监控产品,本身不仅完整的指标体系,还拥有丰富的指标采集解决方案。通过各种exporter可以覆盖中间件,操作系统,开发语言等等方面的监控指标采集 对于在使用 open-falcon 的用户,你也可以通过 prometheus-exporter-collector 将收集到的数据发送给 open-falcon。 ./prometheus-exporter-colle

  • 主要内容:1.Prometheus简介,2.Prometheus优势,Prometheus架构,3.安装,4.启动,5.PromSQL,6.Prometheus和grafana1.Prometheus简介 Prometheus受启发于Google的Brogmon监控系统(相似的Kubernetes是从Google的Brog系统演变而来),从2012年开始由前Google工程师在Soundcloud以开源软件的形式进行研发,并且于2015年早期对外发布早期版本。2016年5月继Kubernetes

  • kube-prometheus Note that everything is experimental and may change significantly at any time. This repository collects Kubernetes manifests, Grafana dashboards, and Prometheus rules combined with doc