{"id":1552,"date":"2023-03-25T15:38:18","date_gmt":"2023-03-25T07:38:18","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1552"},"modified":"2023-03-25T15:38:18","modified_gmt":"2023-03-25T07:38:18","slug":"influxdb-jmeter-grafana","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/influxdb-jmeter-grafana\/","title":{"rendered":"InfluxDB + Jmeter + Grafana"},"content":{"rendered":"<h2>InfluxDB<\/h2>\n<p>influxDB\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u65f6\u5e8f\u3001\u65f6\u95f4\u548c\u6307\u6807\u6570\u636e\u5e93\uff0c\u4f7f\u7528go\u8bed\u8a00\u7f16\u5199\uff0c\u65e0\u9700\u5916\u90e8\u4f9d\u8d56\u3002<\/p>\n<p>\u5b83\u6709\u4e09\u5927\u7279\u6027\uff1a<\/p>\n<p><!-- more --><\/p>\n<ul>\n<li>\u65f6\u5e8f\u6027\uff08Time Series\uff09\uff1a\u4e0e\u65f6\u95f4\u76f8\u5173\u7684\u51fd\u6570\u7684\u7075\u6d3b\u4f7f\u7528\uff08\u8bf8\u5982\u6700\u5927\u3001\u6700\u5c0f\u3001\u6c42\u548c\u7b49\uff09<\/li>\n<li>\u5ea6\u91cf\uff08Metrics\uff09\uff1a\u5bf9\u5b9e\u65f6\u5927\u91cf\u6570\u636e\u8fdb\u884c\u8ba1\u7b97<\/li>\n<li>\u4e8b\u4ef6\uff08Event\uff09\uff1a\u652f\u6301\u4efb\u610f\u7684\u4e8b\u4ef6\u6570\u636e\uff0c\u4efb\u610f\u4e8b\u4ef6\u7684\u6570\u636e\u90fd\u53ef\u4ee5\u505a\u64cd\u4f5c<\/li>\n<\/ul>\n<p>\u540c\u65f6\uff0c\u5b83\u6709\u4ee5\u4e0b\u51e0\u5927\u7279\u70b9\uff1a<\/p>\n<ul>\n<li>schemaless(\u65e0\u7ed3\u6784)\uff0c\u53ef\u4ee5\u662f\u4efb\u610f\u6570\u91cf\u7684\u5217<\/li>\n<li>min, max, sum, count, mean, median \u4e00\u7cfb\u5217\u51fd\u6570\uff0c\u65b9\u4fbf\u7edf\u8ba1<\/li>\n<li>Native HTTP API, \u5185\u7f6ehttp\u652f\u6301\uff0c\u4f7f\u7528http\u8bfb\u5199<\/li>\n<li>Powerful Query Language \u7c7b\u4f3csql<\/li>\n<li>Built-in Explorer \u81ea\u5e26\u7ba1\u7406\u5de5\u5177<\/li>\n<\/ul>\n<h3>InfluxDB\u5b89\u88c5<\/h3>\n<p>\u5b98\u65b9\u5b89\u88c5\u6587\u6863\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/docs.influxdata.com\/influxdb\/v1.7\/introduction\/installation\/\">https:\/\/docs.influxdata.com\/influxdb\/v1.7\/introduction\/installation\/<\/a><br \/>\n\u5b98\u7f51\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/portal.influxdata.com\/downloads\">https:\/\/portal.influxdata.com\/downloads<\/a><\/p>\n<p>influxDB\u7aef\u53e3\uff1a<code>8086<\/code>\u3002\u5373http\u8fde\u63a5influxdb client\u7aef\u53e3\uff0c\u4e00\u822c\u4f7f\u7528\u8be5\u7aef\u53e3\u5f80\u672c\u673a\u7684Influxdb\u8bfb\u5199\u6570\u636e<\/p>\n<p>\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u8bbf\u95ee\u865a\u62df\u673aIP\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/192.168.18.128:8086\/\">http:\/\/192.168.18.128:8086\/<\/a><\/p>\n<p>\u63d0\u793a<code>404 page not found<\/code>\u5373\u4ee3\u8868\u5b89\u88c5\u5e76\u542f\u52a8\u6210\u529f\uff0c\u5b98\u65b91.3\u53ca\u4ee5\u4e0a\u5df2\u7ecf\u79fb\u9664web\u9875\u9762\u76d1\u63a7<\/p>\n<p>\u4e5f\u53ef\u4ee5\u901a\u8fc7\u68c0\u67e5\u7aef\u53e3\u67e5\u770b\u662f\u5426\u542f\u52a8\u6210\u529f<\/p>\n<pre><code># netstat -tlnpu |grep influxd<\/code><\/pre>\n<h3>InfluxDB\u914d\u7f6e<\/h3>\n<p>\u4fee\u6539influxDB\u7684\u914d\u7f6e\uff0c\u4e3b\u8981\u914d\u7f6ejmeter\u5b58\u50a8\u7684\u6570\u636e\u5e93\u4e0e\u7aef\u53e3\u53f7\uff0c\u627e\u5230<code>[http]<\/code>\u3001<code>[[graphite]]<\/code>\uff08\u53ef\u9009\uff09\u8282\u70b9\uff0cenabled\u6539\u4e3atrue\uff0cbind-address\u4fee\u6539\u7ed1\u5b9a\u7684IP\u548c\u7aef\u53e3\uff1a<\/p>\n<pre><code>[[graphite]]\n  # Determines whether the graphite endpoint is enabled.\n  enabled = true\n  database = &quot;jmeter&quot;\n  # retention-policy = &quot;&quot;\n  bind-address = &quot;:2003&quot;\n  protocol = &quot;tcp&quot;\n  consistency-level = &quot;one&quot;\n\n[http]\n  # Determines whether HTTP endpoint is enabled.\n  enabled = true\n\n  # Determines whether the Flux query endpoint is enabled.\n  # flux-enabled = false\n\n  # Determines whether the Flux query logging is enabled.\n  # flux-log-enabled = false\n\n  # The bind address used by the HTTP service.\n  bind-address = &quot;:8086&quot;<\/code><\/pre>\n<ul>\n<li><code>8086<\/code>\u7aef\u53e3\u662fGrafana\u7528\u6765\u4ece\u6570\u636e\u5e93\u53d6\u6570\u636e\u7684\u7aef\u53e3<\/li>\n<li><code>2003<\/code>\u7aef\u53e3\u5219\u662fJmeter\u5f80\u6570\u636e\u5e93\u53d1\u6570\u636e\u7684\u7aef\u53e3<\/li>\n<\/ul>\n<p>\u91cd\u542f\u751f\u6548<\/p>\n<pre><code>\/usr\/local\/influxdb\/usr\/bin\/influxd -config \/usr\/local\/influxdb\/etc\/influxdb\/influxdb.conf &amp;<\/code><\/pre>\n<h2>Grafana<\/h2>\n<p>\u5b89\u88c5\u5e76\u542f\u52a8Grafana\uff0c\u5e76\u5728influxdb\u6dfb\u52a0\u6570\u636e\u5e93<code>jmeter<\/code><\/p>\n<pre><code>create database jmeter;<\/code><\/pre>\n<p>\u6253\u5f00Grafana\u63a7\u5236\u53f0\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"http:\/\/192.168.180.128:3000\">http:\/\/192.168.180.128:3000<\/a> \uff0c\u6dfb\u52a0\u9700\u8981\u5c55\u793a\u6570\u636e\u7684\u6570\u636e\u5e93\uff08\u914d\u7f6eInfluxDB\uff09<\/p>\n<p>\u6dfb\u52a0InfluxDB\u6570\u636e\u5e93\u914d\u7f6e\u3002Database\u4e3a<code>jmeter<\/code>\uff0c\u5e10\u53f7\u5bc6\u7801\u4e3a<code>admin\/admin<\/code>\uff0c\u70b9\u51fb<code>Test &amp; Save<\/code>\u63d0\u793a\u6210\u529f\u5373\u53ef<\/p>\n<h2>JMeter<\/h2>\n<p>\u5b98\u65b9\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/jmeter.apache.org\/download_jmeter.cgi\">https:\/\/jmeter.apache.org\/download_jmeter.cgi<\/a><\/p>\n<p>JMeter\u4e2d\uff0c\u6dfb\u52a0 <code>Thread Group<\/code>\uff0c\u52fe\u9009<code>Forever<\/code>\uff0c\u8bbe\u7f6e\u5faa\u73af\u8fd0\u884c\uff0c\u5e76\u5728\u7ebf\u7a0b\u7ec4\u4e0b\uff1a<\/p>\n<p>\uff081\uff09\u6dfb\u52a0\u540e\u53f0\u76d1\u542c\uff1a<code>Add<\/code> -&gt; <code>Listener<\/code> -&gt; <code>Backend Listener<\/code><\/p>\n<p><code>Backend Listener implementation<\/code>\u9009\u62e9<code>org.apache.jmeter.visualizers.backend.influxdb.influxdbBackendListenerClient<\/code><\/p>\n<pre><code>influxdbMetricsSender: org.apache.jmeter.visualizers.backend.influxdb.HttpMetricsSender\ninfluxdbUrl: http:\/\/192.168.16.20:8086\/write?db=jmeter\napplication: jmeter\nmeasurement: jmeter\nsummaryOnly: true\nsamplersRegex: .*\npercentiles: 90;95;99\ntestTitle: test\neventTags: test<\/code><\/pre>\n<p>\uff082\uff09\u6dfb\u52a0HTTP\u8bf7\u6c42\uff1a<code>Add<\/code> -&gt; <code>Sampler<\/code> -&gt; <code>HTTP Request<\/code>\uff0c<code>HTTP Request Path<\/code>\u8bbe\u7f6e\u4e3a<code>http:\/\/www.baidu.com<\/code><\/p>\n<p>\u80fd\u6b63\u5e38\u8dd1\u901a\u4e4b\u540e\uff0c\u5373\u53ef\u914d\u7f6eGrafana\u4ece\u6570\u636e\u5e93\u4e2d\u8bfb\u53d6\u6570\u636e\u6765\u5c55\u793a<\/p>\n<h2>\u914d\u7f6eGrafana Dashboard<\/h2>\n<p>Apache JMeter Dashboard using Core InfluxdbBackendListenerClient\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/grafana.com\/grafana\/dashboards\/5496\">https:\/\/grafana.com\/grafana\/dashboards\/5496<\/a><br \/>\nJMeter Dashboard\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/grafana.com\/grafana\/dashboards\/4026\">https:\/\/grafana.com\/grafana\/dashboards\/4026<\/a><\/p>\n<h2>\u81ea\u5b9a\u4e49\u56fe\u8868<\/h2>\n<p>\u6dfb\u52a0Mixed\u6570\u636e\u6e90\uff0c\u518d\u5f80\u5176\u4e2d\u6dfb\u52a0\u4e00\u4e2aGrafana\u6570\u636e\u6e90\u548c2\u4e2aJmeter\u6570\u636e\u6e90<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">\u540d\u79f0<\/th>\n<th style=\"text-align: center;\">\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\"><code>jmeter.all.h.count<\/code><\/td>\n<td style=\"text-align: center;\">\u6240\u6709\u8bf7\u6c42\u7684TPS<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\"><code>jmeter.&lt;\u8bf7\u6c42\u540d\u79f0&gt;.h.count<\/code><\/td>\n<td style=\"text-align: center;\">\u5bf9\u5e94&lt;\u8bf7\u6c42\u540d\u79f0&gt;\u7684TPS<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\"><code>jmeter.all.ok.pct99<\/code><\/td>\n<td style=\"text-align: center;\">99%\u7684\u8bf7\u6c42\u54cd\u5e94\u65f6\u95f4<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\"><code>jmeter.&lt;\u8bf7\u6c42\u540d\u79f0&gt;.ok.pct99<\/code><\/td>\n<td style=\"text-align: center;\">\u5bf9\u5e94&lt;\u8bf7\u6c42\u540d\u79f0&gt;99%\u7684\u8bf7\u6c42\u54cd\u5e94\u65f6\u95f4<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\"><code>jmeter.all.test.startedT<\/code><\/td>\n<td style=\"text-align: center;\">\u7ebf\u7a0b\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5982\u679c\u8981\u76d1\u63a7&lt;\u8bf7\u6c42\u540d\u79f0&gt;\u7684\u8bdd\uff0cJmeter\u4e0a\u7684<code>Backend Listener<\/code>\u4fee\u6539\u5982\u4e0b\u53c2\u6570<\/p>\n<ol>\n<li>\u5c06<code>summanyOnly<\/code>\u4fee\u6539\u6210<code>false<\/code><\/li>\n<li>\u5c06<code>userRegexpForSamplersList<\/code>\u4fee\u6539\u6210<code>true<\/code><\/li>\n<li>\u5e76\u4e14\u8981\u8bbe\u7f6e<code>samplersList<\/code>\u7684\u503c\uff0c\u5982\uff1a<code>.*appblog.*<\/code>\uff0c<code>samplersList<\/code>\u662f\u53ef\u4ee5\u652f\u6301\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\uff0c<code>samplersList<\/code>\u7684\u8bbe\u7f6e\u8981\u4e0e\u8bf7\u6c42\u5bf9\u5e94\uff0c\u5426\u5219\u627e\u4e0d\u5230\u8be5\u8bf7\u6c42<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>InfluxDB influxDB\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u5206\u5e03\u5f0f\u65f6\u5e8f\u3001\u65f6\u95f4\u548c\u6307\u6807\u6570\u636e\u5e93\uff0c\u4f7f\u7528go\u8bed\u8a00\u7f16\u5199\uff0c\u65e0\u9700\u5916\u90e8\u4f9d\u8d56\u3002  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[386],"tags":[385,302,231],"class_list":["post-1552","post","type-post","status-publish","format-standard","hentry","category-monitor","tag-grafana","tag-influxdb","tag-jmeter"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1552","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1552"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1552\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}