{"id":26292,"date":"2025-07-02T11:22:02","date_gmt":"2025-07-02T18:22:02","guid":{"rendered":"https:\/\/tdengine.com\/?p=26292"},"modified":"2025-07-28T15:18:02","modified_gmt":"2025-07-28T22:18:02","slug":"interconnecting-tsdbs-prometheus-and-tdengine","status":"publish","type":"post","link":"https:\/\/tdengine.com\/interconnecting-tsdbs-prometheus-and-tdengine\/","title":{"rendered":"Interconnecting TSDBs: Prometheus and TDengine"},"content":{"rendered":"\n<p><a href=\"https:\/\/prometheus.io\" rel=\"noopener\">Prometheus<\/a> is an open-source monitoring and alerting toolkit widely adopted for its powerful time-series data model, flexible query language (PromQL), and efficient pull-based architecture. Prometheus excels at collecting metrics from a wide range of systems and applications, making it a go-to solution for IT infrastructure and application monitoring.<\/p>\n\n\n\n<p>TDengine is a high-performance time-series database purpose-built for industrial and real-time analytics scenarios. It features a compact storage engine, native stream processing, and SQL compatibility. With built-in connectors and low resource consumption, TDengine provides a lightweight yet powerful backend for managing massive volumes of time-stamped data efficiently.<\/p>\n\n\n\n<p>This article demonstrates how to interconnect these systems in two ways:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>remote_write \/ remote_read from Prometheus \u2192 TDengine<\/li>\n\n\n\n<li>TDengine\u2019s <code class=\"\" data-line=\"\">\/metrics<\/code> endpoint scraped by Prometheus<\/li>\n<\/ol>\n\n\n\n<h2 class=\"gb-text\">Prerequisites<\/h2>\n\n\n\n<p>Make sure the following are in place:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A running TDengine cluster<\/li>\n\n\n\n<li>taosAdapter installed and running<\/li>\n\n\n\n<li>Prometheus installed and running<\/li>\n<\/ul>\n\n\n\n<h2 class=\"gb-text\">Remote Read and Write Between Prometheus and TDengine<\/h2>\n\n\n\n<ol>\n<li>\n<p>Create the <code class=\"\" data-line=\"\">prometheus_data<\/code> database in TDengine:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-sql\" data-line=\"\">CREATE DATABASE prometheus_data;<\/code><\/pre>\n<\/li>\n\n\n\n<li>\n<p>Add the following configuration items to <code class=\"\" data-line=\"\">prometheus.yml<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-yaml\" data-line=\"\">remote_write:\n  - url: &quot;http:\/\/&lt;taosadapter-url&gt;:6041\/prometheus\/v1\/remote_write\/prometheus_data&quot;\n    basic_auth:\n      username: &lt;tdengine-user&gt;\n      password: &lt;tdengine-password&gt;\n\nremote_read:\n  - url: &quot;http:\/\/&lt;taosadapter-url&gt;:6041\/prometheus\/v1\/remote_read\/prometheus_data&quot;\n    basic_auth:\n      username: &lt;tdengine-user&gt;\n      password: &lt;tdengine-password&gt;\n    remote_timeout: 10s\n    read_recent: true<\/code><\/pre>\n\n\n\n<p>Modify the URL, username, and password to match your TDengine deployment.<\/p>\n<\/li>\n\n\n\n<li>\n<p>Restart Prometheus:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-bash\" data-line=\"\">sudo systemctl restart prometheus<\/code><\/pre>\n<\/li>\n\n\n\n<li>\n<p>In TDengine, view the metrics in the <code class=\"\" data-line=\"\">prometheus_data<\/code> database:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-sql\" data-line=\"\">USE prometheus_data;\nSHOW STABLES;\nSELECT * FROM metrics LIMIT 10;<\/code><\/pre>\n<\/li>\n<\/ol>\n\n\n\n<p>You should see frequent samples like <code class=\"\" data-line=\"\">go_gc_duration_seconds<\/code> confirming that <code class=\"\" data-line=\"\">remote_write<\/code> is working.<\/p>\n\n\n\n<h2 class=\"gb-text\">Monitoring TDengine with Prometheus<\/h2>\n\n\n\n<p>taosKeeper exports TDengine metrics in Prometheus format at the <code class=\"\" data-line=\"\">\/metrics<\/code> endpoint so that you can monitor your TDengine cluster in Prometheus.<\/p>\n\n\n\n<ol>\n<li>\n<p>Ensure taosKeeper is running:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-bash\" data-line=\"\">sudo systemctl status taoskeeper<\/code><\/pre>\n<\/li>\n\n\n\n<li>\n<p>Test the metrics endpoint:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-bash\" data-line=\"\">curl http:\/\/&lt;taoskeeper_host&gt;:6041\/metrics<\/code><\/pre>\n\n\n\n<p>You&#8217;ll see Prometheus\u2010style output, for example:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"\" data-line=\"\">taos_connections 5\ntaos_query_latency_seconds{quantile=&quot;0.5&quot;} 0.002<\/code><\/pre>\n<\/li>\n\n\n\n<li>\n<p>In <code class=\"\" data-line=\"\">prometheus.yml<\/code>, add a scrape config for taosKeeper:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-yaml\" data-line=\"\">scrape_configs:\n  - job_name: &quot;tdengine&quot;\n    static_configs:\n      - targets: [&quot;&lt;taoskeeper_host&gt;:6041&quot;]\n<\/code><\/pre>\n<\/li>\n\n\n\n<li>\n<p>Restart Prometheus:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-bash\" data-line=\"\">sudo systemctl restart prometheus<\/code><\/pre>\n<\/li>\n<\/ol>\n\n\n\n<p>You can now see TDengine metrics in Prometheus.<\/p>\n\n\n\n<img decoding=\"async\" width=\"1353\" height=\"629\" class=\"gb-media-346c887c\" alt=\"\" src=\"https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/prom-graph.png?strip=all&sharp=1\" title=\"prom-graph\" srcset=\"https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/prom-graph.png?strip=all&amp;sharp=1 1353w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/prom-graph-300x139.png?strip=all&amp;sharp=1 300w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/prom-graph-1024x476.png?strip=all&amp;sharp=1 1024w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/prom-graph-768x357.png?strip=all&amp;sharp=1 768w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/prom-graph.png?strip=all&amp;sharp=1&amp;w=541 541w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/prom-graph.png?strip=all&amp;sharp=1&amp;w=1082 1082w, https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/prom-graph.png?strip=all&amp;sharp=1&amp;w=450 450w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/>\n","protected":false},"excerpt":{"rendered":"<p>This article demonstrates how to interconnect Prometheus and TDengine.<\/p>\n","protected":false},"author":127,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[21],"tags":[],"ppma_author":[261],"class_list":["post-26292","post","type-post","status-publish","format-standard","hentry","category-engineering"],"authors":[{"term_id":261,"user_id":127,"is_guest":0,"slug":"jfan","display_name":"Jim Fan","avatar_url":"https:\/\/eujqw4hwudm.exactdn.com\/wp-content\/uploads\/jfan-profile-new.jpg?strip=all&#038;sharp=1&#038;resize=96%2C96","1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/posts\/26292","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/users\/127"}],"replies":[{"embeddable":true,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/comments?post=26292"}],"version-history":[{"count":4,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/posts\/26292\/revisions"}],"predecessor-version":[{"id":26300,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/posts\/26292\/revisions\/26300"}],"wp:attachment":[{"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/media?parent=26292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/categories?post=26292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/tags?post=26292"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/tdengine.com\/wp-json\/wp\/v2\/ppma_author?post=26292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}