{"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\/ro\/blog\/administrirovanie\/monitoring-postgres-vnutri-openshift","title":{"rendered":"Monitorizarea postgres \u00een Openshift","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>Bun\u0103 ziua, cet\u0103\u021beni ai Habr!<\/p>\n<p>Ast\u0103zi vreau s\u0103 v\u0103 povestesc cum ne-am dorit foarte mult s\u0103 monitoriz\u0103m postgres \u0219i alte c\u00e2teva entit\u0103\u021bi din cadrul clusterei OpenShift \u0219i cum am reu\u0219it s\u0103 facem asta.<\/p>\n<p>Am avut la intrare:<\/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 \/>\nPentru a lucra cu aplica\u021bia Java, totul a fost destul de simplu \u0219i transparent, iar dac\u0103 s\u0103 fiu mai precis, atunci:<\/p>\n<p>1) Ad\u0103ugarea \u00een build.gradle <\/p>\n<pre><code class=\"plaintext\"> implementation \"io.micrometer:micrometer-registry-prometheus\"<\/code><\/pre>\n<p>\n2) Pornirea Prometheus cu configura\u021bia <\/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) Ad\u0103ugarea vizualiz\u0103rii \u00een Grafana <\/p>\n<p>Totul a fost destul de simplu \u0219i previzibil p\u00e2n\u0103 c\u00e2nd a venit momentul s\u0103 monitoriz\u0103m bazele de date care se afl\u0103 aproape de noi \u00een namespace (da, e r\u0103u, nimeni nu face asta, dar se \u00eent\u00e2mpl\u0103 diverse).<\/p>\n<h3>Cum func\u021bioneaz\u0103 acest lucru? <\/h3>\n<p>\nPe l\u00e2ng\u0103 pod-ul cu postgres \u0219i, \u00een mod evident, Prometheus, avem nevoie de o alt\u0103 entitate \u2013 exporter.<\/p>\n<p>Exporterul este, \u00een termeni generali, un agent care colecteaz\u0103 metrici de la aplica\u021bie sau chiar <a class=\"wpil_keyword_link\" href=\"https:\/\/prohoster.info\/ro\/server\/dts-los-angeles\/\"   title=\"server\" data-wpil-keyword-link=\"linked\"  data-wpil-monitor-id=\"3521\">server<\/a>. Exporterul pentru postgres este scris \u00een Go, func\u021bioneaz\u0103 pe principiul rul\u0103rii scripturilor SQL pe baz\u0103 \u0219i apoi rezultatele ob\u021binute sunt preluate de Prometheus. Acest lucru permite, de asemenea, extinderea metricelor colectate prin ad\u0103ugarea celor proprii.<\/p>\n<p>\u00cel depunem \u00een acest mod (exemplu deployment.yaml, f\u0103r\u0103 nicio obliga\u021bie):<\/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>\nDe asemenea, am avut nevoie de un serviciu \u0219i de un imagestream pentru acesta.<\/p>\n<p>Dup\u0103 desf\u0103\u0219urarea noastr\u0103, ne dorim foarte mult ca toate s\u0103 se vad\u0103 reciproc.<\/p>\n<p>Ad\u0103ug\u0103m \u00een configura\u021bia lui Prometheus acest fragment:<\/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>\n\u0218i aici totul a \u00eenceput s\u0103 func\u021bioneze, r\u0103m\u00e2ne s\u0103 ad\u0103ug\u0103m toate acestea \u00een Grafana \u0219i s\u0103 ne bucur\u0103m de rezultat.<\/p>\n<p>Pe l\u00e2ng\u0103 posibilitatea de a ad\u0103uga propriile cereri, \u00een prometheus se pot modifica set\u0103rile pentru a colecta metrici mai \u021bintite.<\/p>\n<p>\u00cen mod similar a fost realizat pentru:<\/p>\n<ul>\n<li>Kafka<\/li>\n<li>Elasticsearch<\/li>\n<li>Mongo<\/li>\n<\/ul>\n<p>\nP.S. Toate datele referitoare la nume, porturi \u0219i alte informa\u021bii au fost inventate \u0219i nu con\u021bin nicio relevan\u021b\u0103. <\/p>\n<p>Linkuri utile:<br \/>\n<noindex><a rel=\"nofollow\" href=\"https:\/\/prometheus.io\/docs\/instrumenting\/exporters\/\">Lista diferitelor exportatori<\/a><\/noindex><br \/>\n<br \/>Sursa: <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\/ro\/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=\"ro_RO\" \/>\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\/ro\/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\udd47Monitorizarea postgres \u00een Openshift | ProHoster","description":"Bun\u0103 ziua, locuitori ai Habrului! Ast\u0103zi vreau s\u0103 v\u0103 povestesc cum ne-am dorit foarte mult s\u0103 monitoriz\u0103m postgres \u0219i \u00eenc\u0103 c\u00e2teva entit\u0103\u021bi din cadrul cluster-ului OpenShift \u0219i cum am reu\u0219it s\u0103 facem acest lucru. Am avut urm\u0103toarele:","canonical_url":"https:\/\/prohoster.info\/ro\/blog\/administrirovanie\/monitoring-postgres-vnutri-openshift","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"ro_RO","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\/ro\/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\/ro\/wp-json\/wp\/v2\/posts\/38253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/ro\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/ro\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/ro\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/ro\/wp-json\/wp\/v2\/comments?post=38253"}],"version-history":[{"count":1,"href":"https:\/\/prohoster.info\/ro\/wp-json\/wp\/v2\/posts\/38253\/revisions"}],"predecessor-version":[{"id":162047,"href":"https:\/\/prohoster.info\/ro\/wp-json\/wp\/v2\/posts\/38253\/revisions\/162047"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/ro\/wp-json\/wp\/v2\/media?parent=38253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/ro\/wp-json\/wp\/v2\/categories?post=38253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/ro\/wp-json\/wp\/v2\/tags?post=38253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}