{"id":3436,"date":"2021-09-20T13:47:43","date_gmt":"2021-09-20T04:47:43","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=3436"},"modified":"2021-09-22T21:11:08","modified_gmt":"2021-09-22T12:11:08","slug":"thanos","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=3436","title":{"rendered":"<\uc791\uc5c5\uc911> Thanos"},"content":{"rendered":"<h1>Thanos<\/h1>\n<p><a href=\"https:\/\/johansiebens.dev\/posts\/2020\/12\/monitoring-nomad-with-prometheus-and-thanos\/\">\ucc38\uc870<\/a><\/p>\n<h2>Prometheus \uc758 \ud55c\uacc4\uc810<\/h2>\n<h3>scale-out \uae30\ub2a5\uc758 \ubd80\uc7ac<\/h3>\n<p>single \uc11c\ubc84\ub85c \uad6c\ud604\ub418\uc5b4 scale-out \uc744 \ud560 \uc218 \uc5c6\ub2e4.<\/p>\n<h3>\uace0\uac00\uc6a9\uc131<\/h3>\n<p>\uc5ed\uc2dc single \uc11c\ubc84\ub85c \uad6c\ud604\ub418\uc5b4 Prometheus \ub2e4\uc6b4 \ub610\ub294 \ubc84\uc804\uc5c5\uc744 \uc704\ud55c shutdown \uc2dc \ubaa8\ub2c8\ud130\ub9c1\uc774 \uc911\uc9c0\ub41c\ub2e4.<\/p>\n<h2>Thanos \uc758 \uc7a5\uc810<\/h2>\n<h3>Global Query View<\/h3>\n<p>\ub2e4\uc218\uc758 Prometheus \uc11c\ubc84\uc5d0\uc11c \uc218\uc9d1\ub41c \ub85c\uadf8\uc5d0 \ub300\ud574 \ud55c\ubc88\uc5d0 \uc870\ud68c\ud560 \uc218 \uc788\ub2e4.<\/p>\n<h3>Unlimited Retention<\/h3>\n<p>\uc800\uc7a5\ub41c \ub85c\uadf8\ub97c S3 \uc640 \uac19\uc740 \uc678\ubd80 \uc800\uc7a5\uacf5\uac04\uc5d0 \uc800\uc7a5\ud560 \uc218 \uc788\ub2e4.<br \/>\n\ub530\ub77c\uc11c, \ub85c\uceec \uc2a4\ud1a0\ub9ac\uc9c0\uc758 \ud55c\uacc4\ub85c \uc778\ud55c \uc800\uc7a5 \uae30\uac04\uc758 \uc81c\ud55c\uc774 \uc5c6\ub2e4.<\/p>\n<h3>Prometheus Compatible<\/h3>\n<p>Prometheus \uc758 \ud55c\uacc4\uc810\uc744 \ucee4\ubc84\ud574\uc900\ub2e4.<\/p>\n<h3>Downsampling &amp; Compaction<\/h3>\n<p>\uc7a5\uae30\uac04\uc758 \ub85c\uadf8\ub97c \uc870\ud68c\ud560 \uacbd\uc6b0, \uc2e4\uc81c \ub370\uc774\ud0c0\ub294 10\ucd08 \uac04\uaca9\uc774\ub77c \ud574\ub3c4,<br \/>\n\uc870\ud68c\uc5d0 \ud544\uc694\ud55c \ub370\uc774\ud0c0\ub294 10\ubd84\uc5d0 \ud55c\uac74\uc73c\ub85c \ub2e4\uc6b4\uc0d8\ud50c\ub9c1\ud560 \uc218 \uc788\ub2e4.<\/p>\n<h2>Thanos architecture<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/www.skyer9.pe.kr\/wordpress\/wp-content\/uploads\/2021\/09\/2021-09-20-02.png\" alt=\"\" \/><\/p>\n<h3>Thanos Sidecar<\/h3>\n<p>Prometheus \uc758 \uc791\ub3d9\uc744 \ubc29\ud574\ud558\uc9c0 \uc54a\uace0, \uc606\uc5d0\uc11c \uac19\uc774 \ub370\uc774\ud0c0\ub97c \uc218\uc9d1\ud569\ub2c8\ub2e4.<\/p>\n<h3>Thanos Store<\/h3>\n<p>\ub85c\uadf8 \ub370\uc774\ud0c0\ub97c \uc800\uc7a5\ud569\ub2c8\ub2e4.<br \/>\nS3 \uc640 \uac19\uc740 \uc678\ubd80 \uc800\uc7a5\uacf5\uac04\uc73c\ub85c \ub85c\uadf8\ub97c \uc804\uc1a1 \ub610\ub294 \ub2e4\uc2dc \uac00\uc838\uc62c \uc218 \uc788\ub2e4.<\/p>\n<h3>Thanos Querier<\/h3>\n<p>\ub2e4\uc218\uc758 Prometheus \uc11c\ubc84\uc5d0\uc11c \uc218\uc9d1\ub41c \ub85c\uadf8\ub97c \ud55c\ubc88\uc5d0 \uc870\ud68c\ud560 \uc218 \uc788\ub2e4.<\/p>\n<h3>Thanos Compactor<\/h3>\n<p>\ub85c\uadf8\ub370\uc774\ud0c0\ub97c \ub2e4\uc6b4\uc0d8\ud50c\ub9c1\ud560 \uc218 \uc788\ub2e4.<\/p>\n<h2>Deploying on HashiCorp Nomad<\/h2>\n<h3>Nomad Cluster \uad6c\uc131<\/h3>\n<p><a href=\"https:\/\/github.com\/skyer9\/NomadClusterForDev\">https:\/\/github.com\/skyer9\/NomadClusterForDev<\/a> \ub97c \ucc38\uc870\ud574\uc11c Test Nomad Cluster \ub97c \uad6c\uc131\ud569\ub2c8\ub2e4.<\/p>\n<p><a href=\"https:\/\/github.com\/skyer9\/TerraformOnAws\/blob\/main\/run_jobs\/haproxy.nomad\">https:\/\/github.com\/skyer9\/TerraformOnAws\/blob\/main\/run_jobs\/haproxy.nomad<\/a> \ub97c \ucc38\uc870\ud574\uc11c reverse proxy \ub97c \ucd94\uac00\ud569\ub2c8\ub2e4.<\/p>\n<h3>\uc124\uc815 \ubcc0\uacbd<\/h3>\n<p>\uc544\ub798 \uba85\ub839\uc73c\ub85c prometheus \ub97c \uc704\ud55c \ub85c\uadf8\ub97c \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-hcl\">sudo vi \/etc\/nomad.d\/nomad.hcl\n---------------------------------------\n......\nclient {\n  host_volume &quot;prometheus&quot; {\n    # add directory manually\n    # sudo mkdir -p \/opt\/nomad-volumes\/prometheus\n    # sudo chown 65534:65534 \/opt\/nomad-volumes\/prometheus\n    path      = &quot;\/opt\/nomad-volumes\/prometheus&quot;\n    read_only = false\n  }\n}\n......\ntelemetry {\n  collection_interval        = &quot;5s&quot;\n  disable_hostname           = true\n  publish_allocation_metrics = true\n  publish_node_metrics       = true\n  prometheus_metrics         = true\n}\n---------------------------------------<\/code><\/pre>\n<h3>cni-plugins \uc124\uce58<\/h3>\n<pre><code class=\"language-bash\">curl -L -o cni-plugins.tgz https:\/\/github.com\/containernetworking\/plugins\/releases\/download\/v0.8.1\/cni-plugins-linux-amd64-v0.8.1.tgz\nsudo mkdir -p \/opt\/cni\/bin\nsudo tar -C \/opt\/cni\/bin -xzf cni-plugins.tgz<\/code><\/pre>\n<h3>prometheus \uc124\uce58<\/h3>\n<p><a href=\"https:\/\/github.com\/skyer9\/TerraformOnAws\/blob\/main\/run_jobs\/prometheus.nomad\">https:\/\/github.com\/skyer9\/TerraformOnAws\/blob\/main\/run_jobs\/prometheus.nomad<\/a> \ub97c \ucc38\uc870\ud574\uc11c prometheus \ub97c \uc124\uce58\ud569\ub2c8\ub2e4.<\/p>\n<p>\ubcfc\ub968\uc744 \ucd94\uac00\ud574 \uc90d\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-nomad\">        args = [\n          &quot;--config.file=\/etc\/prometheus\/config\/prometheus.yml&quot;,\n          &quot;--storage.tsdb.path=\/prometheus&quot;,\n          &quot;--web.listen-address=0.0.0.0:${NOMAD_PORT_prometheus_ui}&quot;,\n          &quot;--web.console.libraries=\/usr\/share\/prometheus\/console_libraries&quot;,\n          &quot;--web.console.templates=\/usr\/share\/prometheus\/consoles&quot;,\n          # for Thanos\n          # &quot;--storage.tsdb.max-block-duration=2h&quot;,\n          # &quot;--storage.tsdb.min-block-duration=2h&quot;,\n        ]\n\njob &quot;prometheus&quot; {\n\n  group &quot;prometheus&quot; {\n    volume &quot;prometheus&quot; {\n      type   = &quot;host&quot;\n      source = &quot;prometheus&quot;\n    }\n\n    task &quot;prometheus&quot; {\n\n      volume_mount {\n        volume      = &quot;prometheus&quot;\n        destination = &quot;\/prometheus&quot;\n      }\n    }\n  }\n}<\/code><\/pre>\n<h3>Thanos \uc124\uce58<\/h3>\n<pre><code class=\"language-nomad\">vi thanos-sidecar.nomad\n---------------------------------------\njob &quot;thanos-sidecar&quot; {\n  datacenters = [&quot;dc1&quot;]\n\n  group &quot;thanos-sidecar&quot; {\n    count = 1\n\n    network {\n      mode = &quot;bridge&quot;\n      port &quot;grpc&quot; {\n        to = 10901\n      }\n      port &quot;http&quot; {\n        to = 10902\n      }\n    }\n\n    service {\n      name = &quot;thanos-sidecar&quot;\n      port = &quot;grpc&quot;\n      tags = [&quot;grpc&quot;]\n    }\n\n    service {\n      name = &quot;thanos-sidecar&quot;\n      port = &quot;http&quot;\n      tags = [&quot;http&quot;]\n    }\n\n    volume &quot;prometheus&quot; {\n      type      = &quot;host&quot;\n      read_only = false\n      source    = &quot;prometheus&quot;\n    }\n\n    task &quot;thanos-sidecar&quot; {\n      driver = &quot;docker&quot;\n\n      volume_mount {\n        volume      = &quot;prometheus&quot;\n        destination = &quot;\/prometheus&quot;\n        read_only   = false\n      }\n\n      template {\n        change_mode = &quot;noop&quot;\n        destination = &quot;local\/bucket.yml&quot;\n\n        data = &lt;&lt;EOH\ntype: S3\nconfig:\n  bucket: &lt;your-bucket-name&gt;\n  endpoint: &lt;your-bucket-endpoint&gt;\n  signature_version2: true\n  access_key: &lt;your-bucket-access-key&gt;\n  secret_key: &lt;your-bucket-secret-key&gt;\nEOH\n      }\n\n      config {\n        image = &quot;quay.io\/thanos\/thanos:v0.22.0&quot;\n\n        auth_soft_fail = true\n\n        # host \ub85c \uc124\uc815\ud588\uc73c\ubbc0\ub85c 127.0.0.1 \ub294 \ud638\uc2a4\ud2b8\ub97c \uac00\ub974\ud0a8\ub2e4.\n        network_mode = &quot;host&quot;\n\n        args = [\n          &quot;sidecar&quot;,\n          &quot;--tsdb.path=\/prometheus&quot;,\n          &quot;--prometheus.url=http:\/\/localhost:9090\/&quot;,\n          &quot;--grpc-address=0.0.0.0:10901&quot;,\n          &quot;--http-address=0.0.0.0:10902&quot;,\n          &quot;--objstore.config-file=\/etc\/thanos\/bucket.yml&quot;\n        ]\n\n        volumes = [\n          &quot;local\/bucket.yml:\/etc\/thanos\/bucket.yml&quot;,\n        ]\n      }\n\n      resources {\n        memory = 1024\n      }\n    }\n  }\n}\n---------------------------------------<\/code><\/pre>\n<pre><code class=\"language-nomad\">vi thanos-store.nomad\n---------------------------------------\njob &quot;thanos-store&quot; {\n  datacenters = [&quot;dc1&quot;]\n\n  group &quot;thanos-store&quot; {\n    count = 1\n\n    network {\n      mode = &quot;bridge&quot;\n      port &quot;grpc&quot; {\n        to = 10901\n      }\n      port &quot;http&quot; {\n        to = 10902\n      }\n    }\n\n    service {\n      name = &quot;thanos-store&quot;\n      port = &quot;grpc&quot;\n      tags = [&quot;grpc&quot;]\n    }\n\n    service {\n      name = &quot;thanos-store&quot;\n      port = &quot;http&quot;\n      tags = [&quot;http&quot;]\n    }\n\n    task &quot;thanos-store&quot; {\n      driver = &quot;docker&quot;\n\n      template {\n        change_mode = &quot;noop&quot;\n        destination = &quot;local\/bucket.yml&quot;\n\n        data = &lt;&lt;EOH\ntype: S3\nconfig:\n  bucket: &lt;your-bucket-name&gt;\n  endpoint: &lt;your-bucket-endpoint&gt;\n  signature_version2: true\n  access_key: &lt;your-bucket-access-key&gt;\n  secret_key: &lt;your-bucket-secret-key&gt;\nEOH\n      }\n\n      config {\n        image = &quot;quay.io\/thanos\/thanos:v0.22.0&quot;\n\n        # host \ub85c \uc124\uc815\ud588\uc73c\ubbc0\ub85c 127.0.0.1 \ub294 \ud638\uc2a4\ud2b8\ub97c \uac00\ub974\ud0a8\ub2e4.\n        network_mode = &quot;host&quot;\n\n        auth_soft_fail = true\n\n        args = [\n          &quot;store&quot;,\n          &quot;--grpc-address=0.0.0.0:10901&quot;,\n          &quot;--http-address=0.0.0.0:10902&quot;,\n          &quot;--objstore.config-file=\/etc\/thanos\/bucket.yml&quot;\n        ]\n\n        volumes = [\n          &quot;local\/bucket.yml:\/etc\/thanos\/bucket.yml&quot;,\n        ]\n      }\n    }\n  }\n}\n---------------------------------------<\/code><\/pre>\n<pre><code class=\"language-nomad\">vi thanos-query.nomad\n---------------------------------------\njob &quot;thanos-query&quot; {\n  datacenters = [&quot;dc1&quot;]\n\n  group &quot;thanos-query&quot; {\n    count = 1\n\n    network {\n      mode = &quot;bridge&quot;\n      port &quot;http&quot; {\n        to = 10902\n      }\n    }\n\n    service {\n      name = &quot;thanos-query&quot;\n      port = &quot;http&quot;\n\n      check {\n        name     = &quot;thanos query port alive&quot;\n        type     = &quot;http&quot;\n        path     = &quot;\/-\/healthy&quot;\n        interval = &quot;10s&quot;\n        timeout  = &quot;2s&quot;\n      }\n    }\n\n    task &quot;thanos-query&quot; {\n      driver = &quot;docker&quot;\n\n      template {\n        change_mode = &quot;restart&quot;\n        destination = &quot;local\/targets.yml&quot;\n\n        data = &lt;&lt;EOH\n- targets:{{ range service &quot;thanos-sidecar&quot; }}{{if .Tags | contains &quot;grpc&quot;}}\n    - &#039;{{ .Address }}:{{ .Port }}&#039;{{ end }}{{ end }}\n- targets:{{ range service &quot;thanos-store&quot; }}{{if .Tags | contains &quot;grpc&quot;}}\n    - &#039;{{ .Address }}:{{ .Port }}&#039;{{ end }}{{ end }}\nEOH\n      }\n\n      config {\n        image = &quot;quay.io\/thanos\/thanos:v0.22.0&quot;\n\n        # host \ub85c \uc124\uc815\ud588\uc73c\ubbc0\ub85c 127.0.0.1 \ub294 \ud638\uc2a4\ud2b8\ub97c \uac00\ub974\ud0a8\ub2e4.\n        network_mode = &quot;host&quot;\n\n        auth_soft_fail = true\n\n        args = [\n          &quot;query&quot;,\n          &quot;--grpc-address=0.0.0.0:10901&quot;,\n          &quot;--http-address=0.0.0.0:10902&quot;,\n          &quot;--query.replica-label=prometheus_replica&quot;,\n          &quot;--query.replica-label=rule_replica&quot;,\n          &quot;--store.sd-files=\/etc\/targets.yml&quot;,\n          &quot;--web.external-prefix=\/thanos\/&quot;,\n          &quot;--web.route-prefix=\/thanos\/&quot;\n        ]\n\n        volumes = [\n          &quot;local\/targets.yml:\/etc\/targets.yml&quot;,\n        ]\n      }\n    }\n  }\n}\n---------------------------------------<\/code><\/pre>\n<pre><code class=\"language-nomad\">vi thanos-compactor.nomad\n---------------------------------------\njob &quot;thanos-compactor&quot; {\n  datacenters = [&quot;dc1&quot;]\n\n  group &quot;thanos-compactor&quot; {\n    count = 1\n\n    network {\n      mode = &quot;bridge&quot;\n      port &quot;grpc&quot; {\n        to = 10901\n      }\n      port &quot;http&quot; {\n        to = 10902\n      }\n    }\n\n    service {\n      name = &quot;thanos-compactor&quot;\n      port = &quot;grpc&quot;\n      tags = [&quot;grpc&quot;]\n    }\n\n    service {\n      name = &quot;thanos-compactor&quot;\n      port = &quot;http&quot;\n      tags = [&quot;http&quot;]\n    }\n\n    task &quot;thanos-compactor&quot; {\n      driver = &quot;docker&quot;\n\n      template {\n        change_mode = &quot;noop&quot;\n        destination = &quot;local\/bucket.yml&quot;\n\n        data = &lt;&lt;EOH\ntype: S3\nconfig:\n  bucket: &lt;your-bucket-name&gt;\n  endpoint: &lt;your-bucket-endpoint&gt;\n  signature_version2: true\n  access_key: &lt;your-bucket-access-key&gt;\n  secret_key: &lt;your-bucket-secret-key&gt;\nEOH\n      }\n\n      config {\n        image = &quot;quay.io\/thanos\/thanos:v0.22.0&quot;\n\n        # host \ub85c \uc124\uc815\ud588\uc73c\ubbc0\ub85c 127.0.0.1 \ub294 \ud638\uc2a4\ud2b8\ub97c \uac00\ub974\ud0a8\ub2e4.\n        network_mode = &quot;host&quot;\n\n        auth_soft_fail = true\n\n        args = [\n          &quot;compact&quot;,\n          &quot;--wait&quot;,\n          &quot;--objstore.config-file=\/etc\/thanos\/bucket.yml&quot;\n        ]\n\n        volumes = [\n          &quot;local\/bucket.yml:\/etc\/thanos\/bucket.yml&quot;,\n        ]\n      }\n    }\n  }\n}\n---------------------------------------<\/code><\/pre>\n<pre><code class=\"language-configuration\">\n      port &quot;thanos_http&quot; {\n        static = 10902\n      }\n\nfrontend thanos_http_front\n   bind *:{{ env &quot;NOMAD_PORT_thanos_http&quot; }}\n   default_backend thanos_http_back\n\nbackend thanos_http_back\n   balance roundrobin\n   server-template thanos_http 5 _thanos-query._tcp.service.consul resolvers consul resolve-opts allow-dup-ip resolve-prefer ipv4 check<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Thanos \ucc38\uc870 Prometheus \uc758 \ud55c\uacc4\uc810 scale-out \uae30\ub2a5\uc758 \ubd80\uc7ac single \uc11c\ubc84\ub85c \uad6c\ud604\ub418\uc5b4 scale-out \uc744 \ud560 \uc218 \uc5c6\ub2e4. \uace0\uac00\uc6a9\uc131 \uc5ed\uc2dc single \uc11c\ubc84\ub85c \uad6c\ud604\ub418\uc5b4 Prometheus \ub2e4\uc6b4 \ub610\ub294 \ubc84\uc804\uc5c5\uc744 \uc704\ud55c shutdown \uc2dc \ubaa8\ub2c8\ud130\ub9c1\uc774 \uc911\uc9c0\ub41c\ub2e4. Thanos \uc758 \uc7a5\uc810 Global Query View \ub2e4\uc218\uc758 Prometheus \uc11c\ubc84\uc5d0\uc11c \uc218\uc9d1\ub41c \ub85c\uadf8\uc5d0 \ub300\ud574 \ud55c\ubc88\uc5d0 \uc870\ud68c\ud560 \uc218 \uc788\ub2e4. Unlimited Retention \uc800\uc7a5\ub41c \ub85c\uadf8\ub97c S3 \uc640 \uac19\uc740 \uc678\ubd80 \uc800\uc7a5\uacf5\uac04\uc5d0\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=3436\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-3436","post","type-post","status-publish","format-standard","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3436"}],"version-history":[{"count":14,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3436\/revisions"}],"predecessor-version":[{"id":3473,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3436\/revisions\/3473"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}