{"id":38253,"date":"2019-10-31T22:22:35","date_gmt":"2019-10-31T19:22:35","guid":{"rendered":"https:\/\/prohoster.info\/blog\/monitoring-postgres-vnutri-openshift\/"},"modified":"2019-10-31T22:22:35","modified_gmt":"2019-10-31T19:22:35","slug":"monitoring-postgres-vnutri-openshift","status":"publish","type":"post","link":"https:\/\/prohoster.info\/fr\/blog\/administrirovanie\/monitoring-postgres-vnutri-openshift","title":{"rendered":"Surveillance de Postgres dans Openshift","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>Bonjour \u00e0 tous les habitants de Habr !<\/p>\n<p>Aujourd'hui, je veux vous parler de notre envie de surveiller Postgres et quelques autres entit\u00e9s \u00e0 l'int\u00e9rieur du cluster OpenShift, et comment nous l'avons fait.<\/p>\n<p>Nous avions en entr\u00e9e :<\/p>\n<ul>\n<li>Openshift<\/li>\n<li>Helm<\/li>\n<li>Prometheus<\/li>\n<\/ul>\n<p>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><br \/>\nPour travailler avec l'application Java, tout \u00e9tait plut\u00f4t simple et clair, ou pour \u00eatre plus pr\u00e9cis :<\/p>\n<p>1) Ajout dans build.gradle <\/p>\n<pre><code class=\"plaintext\"> implementation \"io.micrometer:micrometer-registry-prometheus\"<\/code><\/pre>\n<p>\n2) Lancer Prometheus avec la configuration <\/p>\n<pre><code class=\"xml\"> - job_name: 'job-name'\n    metrics_path: '\/actuator\/prometheus'\n    scrape_interval: 5s\n    kubernetes_sd_configs:\n    - role: pod\n      namespaces:\n        names: \n          - 'name'<\/code><\/pre>\n<p>\n3) Ajout de l'affichage dans Grafana <\/p>\n<p>Tout \u00e9tait assez simple et prosa\u00efque jusqu'\u00e0 ce que le moment de surveiller les bases de donn\u00e9es qui se trouvent \u00e0 proximit\u00e9 dans le namespace soit arriv\u00e9 (oui, c'est mal, personne ne fait \u00e7a, mais il y a des circonstances).<\/p>\n<h3>Comment cela fonctionne-t-il ? <\/h3>\n<p>\nEn plus du pod contenant Postgres et de Prometheus lui-m\u00eame, nous avons besoin d'une autre entit\u00e9 : l'exporter.<\/p>\n<p>Un exporter, de mani\u00e8re abstraite, est un agent qui collecte des m\u00e9triques d'une application ou m\u00eame <a class=\"wpil_keyword_link\" href=\"https:\/\/prohoster.info\/fr\/server\/dts-los-angeles\/\"   title=\"de serveurs\" data-wpil-keyword-link=\"linked\"  data-wpil-monitor-id=\"3521\">de serveurs<\/a>. L'exporter pour Postgres est \u00e9crit en Go, fonctionne sur le principe d'ex\u00e9cuter des scripts SQL dans la base, puis r\u00e9cup\u00e8re les r\u00e9sultats obtenus par Prometheus. Cela permet \u00e9galement d'\u00e9largir les m\u00e9triques collect\u00e9es en ajoutant les v\u00f4tres.<\/p>\n<p>Nous le d\u00e9ployons de cette mani\u00e8re (exemple de deployment.yaml, sans engagement) :<\/p>\n<pre><code class=\"xml\">\n---\napiVersion: extensions\/v1beta1\nkind: Deployment\nmetadata:\n  name: postgres-exporter\n  labels:\n    app: {{ .Values.name }}\n    monitoring: prometheus\nspec:\n  serviceName: {{ .Values.name }}\n  replicas: 1\n  revisionHistoryLimit: 5\n  template:\n    metadata:\n      labels:\n        app: postgres-exporter\n        monitoring: prometheus\n    spec:\n      containers:\n      - env:\n        - name: DATA_SOURCE_URI\n          value: postgresdb:5432\/pstgr?sslmode=disable\n        - name: DATA_SOURCE_USER\n          value: postgres\n        - name: DATA_SOURCE_PASS\n          value: postgres\n        resources:\n          limits:\n            cpu: 100m\n            memory: 50Mi\n          requests:\n            cpu: 100m\n            memory: 50Mi\n        livenessProbe:\n          tcpSocket:\n            port: metrics\n          initialDelaySeconds: 30\n          periodSeconds: 30\n        readinessProbe:\n          tcpSocket:\n            port: metrics\n          initialDelaySeconds: 10\n          periodSeconds: 30\n        image: exporter\n        name: postgres-exporter\n        ports:\n        - containerPort: 9187\n          name: metrics<\/code><\/pre>\n<p>\nIl a \u00e9galement besoin d'un service et d'un imagestream.<\/p>\n<p>Apr\u00e8s le d\u00e9ploiement, nous souhaitons vraiment que tout le monde puisse se voir.<\/p>\n<p>Ajoutons dans la configuration de Prometheus un extrait comme celui-ci :<\/p>\n<pre><code class=\"xml\">  - job_name: 'postgres_exporter'\n    metrics_path: '\/metrics'\n    scrape_interval: 5s\n    dns_sd_configs:\n    - names:\n      - 'postgres-exporter'\n      type: 'A'\n      port: 9187<\/code><\/pre>\n<p>\nEt \u00e0 ce moment-l\u00e0, tout a fonctionn\u00e9, il ne reste plus qu'\u00e0 ajouter tout cela dans Grafana et profiter du r\u00e9sultat.<\/p>\n<p>En plus de la possibilit\u00e9 d'ajouter vos propres requ\u00eates, dans prometheus, il est possible de modifier les param\u00e8tres pour collecter plus pr\u00e9cis\u00e9ment les m\u00e9triques n\u00e9cessaires.<\/p>\n<p>De la m\u00eame mani\u00e8re, cela a \u00e9t\u00e9 fait pour :<\/p>\n<ul>\n<li>Kafka<\/li>\n<li>Elasticsearch<\/li>\n<li>Mongo<\/li>\n<\/ul>\n<p>\nP.S. Toutes les donn\u00e9es concernant les noms, les ports et autres ont \u00e9t\u00e9 invent\u00e9es et ne contiennent aucune information. <\/p>\n<p>Liens utiles :<br \/>\n<noindex><a rel=\"nofollow\" href=\"https:\/\/prometheus.io\/docs\/instrumenting\/exporters\/\">Liste des diff\u00e9rents exportateurs<\/a><\/noindex><br \/>\n<br \/>Source : <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/467915\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a \u0436\u0438\u0442\u0435\u043b\u0438 \u0425\u0430\u0431\u0440\u0430! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c, \u043a\u0430\u043a \u043d\u0430\u043c \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c postgres \u0438 \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 OpenShift \u0438 \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438. \u041d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0438\u043c\u0435\u043b\u0438: Openshift Helm Prometheus \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 java \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0432\u0441\u0435 \u0431\u044b\u043b\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e, \u0430 \u0435\u0441\u043b\u0438 \u0431\u044b\u0442\u044c \u0442\u043e\u0447\u043d\u0435\u0435, \u0442\u043e: 1) \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 build.gradle implementation &#171;io.micrometer:micrometer-registry-prometheus&#187; [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-38253","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a \u0436\u0438\u0442\u0435\u043b\u0438 \u0425\u0430\u0431\u0440\u0430! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c, \u043a\u0430\u043a \u043d\u0430\u043c \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c postgres \u0438 \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 OpenShift \u0438 \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438. \u041d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0438\u043c\u0435\u043b\u0438: .\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/fr\/blog\/administrirovanie\/monitoring-postgres-vnutri-openshift\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"fr_FR\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 postgres \u0432\u043d\u0443\u0442\u0440\u0438 Openshift | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a \u0436\u0438\u0442\u0435\u043b\u0438 \u0425\u0430\u0431\u0440\u0430! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c, \u043a\u0430\u043a \u043d\u0430\u043c \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c postgres \u0438 \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 OpenShift \u0438 \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438. \u041d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0438\u043c\u0435\u043b\u0438: .\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/fr\/blog\/administrirovanie\/monitoring-postgres-vnutri-openshift\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-10-31T19:22:35+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-10-31T19:22:35+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Surveillance de postgres \u00e0 l'int\u00e9rieur d'OpenShift | ProHoster","description":"Bonjour \u00e0 tous les habitants de Habr ! Aujourd'hui, je souhaite vous parler de notre envie de surveiller postgres et quelques autres entit\u00e9s au sein du cluster OpenShift, et comment nous y sommes parvenus. Nous avions : .","canonical_url":"https:\/\/prohoster.info\/fr\/blog\/administrirovanie\/monitoring-postgres-vnutri-openshift","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"fr_FR","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 postgres \u0432\u043d\u0443\u0442\u0440\u0438 Openshift | ProHoster","og:description":"\u0414\u043e\u0431\u0440\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0441\u0443\u0442\u043e\u043a \u0436\u0438\u0442\u0435\u043b\u0438 \u0425\u0430\u0431\u0440\u0430! \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0430\u043c, \u043a\u0430\u043a \u043d\u0430\u043c \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u0442\u044c postgres \u0438 \u0435\u0449\u0435 \u043f\u0430\u0440\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 OpenShift \u0438 \u043a\u0430\u043a \u043c\u044b \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438. \u041d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0438\u043c\u0435\u043b\u0438: .","og:url":"https:\/\/prohoster.info\/fr\/blog\/administrirovanie\/monitoring-postgres-vnutri-openshift","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-10-31T19:22:35+00:00","article:modified_time":"2019-10-31T19:22:35+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"38253","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-02-22 15:56:24","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-03-01 01:12:23","updated":"2026-02-22 15:56:24","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/fr\/wp-json\/wp\/v2\/posts\/38253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/fr\/wp-json\/wp\/v2\/comments?post=38253"}],"version-history":[{"count":1,"href":"https:\/\/prohoster.info\/fr\/wp-json\/wp\/v2\/posts\/38253\/revisions"}],"predecessor-version":[{"id":162047,"href":"https:\/\/prohoster.info\/fr\/wp-json\/wp\/v2\/posts\/38253\/revisions\/162047"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/fr\/wp-json\/wp\/v2\/media?parent=38253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/fr\/wp-json\/wp\/v2\/categories?post=38253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/fr\/wp-json\/wp\/v2\/tags?post=38253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}