我如何从 Gatling 写入 InfluxDB?

How can I write in InfluxDB from Gatling?

我的问题已经有人问过了,但我没有成功解决我的问题。

我没有成功将我的数据从 Gatling 实时发送到 InfluxDB。

我在 Windows 10。 加特林版本:2.3.0(最后一个)。 InfluxDB版本:1.3.5(最后是1.3.6)。

我的gatling.conf:

data {
    writers = [console, file, graphite]      # The list of DataWriters to which Gatling write simulation data (currently supported : console, file, graphite, jdbc)
    console {
      #light = false                # When set to true, displays a light version without detailed request stats
    }
    file {
      #bufferSize = 8192            # FileDataWriter's internal data buffer size, in bytes
    }
    leak {
      #noActivityTimeout = 30  # Period, in seconds, for which Gatling may have no activity before considering a leak may be happening
    }
    graphite {
      #light = false              # only send the all* stats
      host = "127.0.0.1"         # The host where the Carbon server is located
      port = "2003"              # The port to which the Carbon server listens to (2003 is default for plaintext, 2004 is default for pickle)
      protocol = "tcp"           # The protocol used to send data to Carbon (currently supported : "tcp", "udp")
      rootPathPrefix = "gatling" # The common prefix of all metrics sent to Graphite
      #bufferSize = 8192          # GraphiteDataWriter's internal data buffer size, in bytes
      #writeInterval = 1          # GraphiteDataWriter's write interval, in seconds
    }
  }

我的influxdb.conf:

[http]
  # Determines whether HTTP endpoint is enabled.
   enabled = true


  # The bind address used by the HTTP service.
   bind-address = "127.0.0.1:8086"


###
### [[graphite]]
###
### Controls one or many listeners for Graphite data.
###


[[graphite]]
  # Determines whether the graphite endpoint is enabled.
   enabled = true
   database = "gatlingdb"
  # retention-policy = ""
   bind-address = ":2003"
   protocol = "tcp"
  # consistency-level = "one"
   templates = [
       "gatling.*.*.*.*.measurement.simulation.request.status.field"
   ]

我的 gatlingdb 数据库是在 InfluxDB 上创建的,它保持为空。

当我尝试时:

C:\InfluxDB-1.3.5-1>influx -host 127.0.0.1

我已连接到 InfluxDB

>USE gatlingdb

我已连接到我的数据库。那么:

>SHOW SERIES

>SELECT * FROM gatling

什么都不return。它是空的。

注意:我放 "FROM gatling" 因为我把它放在我的 gatling.conf 中: rootPathPrefix = "gatling"

我没有下载 Graphite,但我看到 InfluxDB 接受 Graphite 协议。我假设我可以将数据从 Gatling 发送到 InfluxDB。我当然错过了什么。

我成功将InfluxDB连接到Grafana,并显示了来自其他数据库的数据。我只是错过了 Gatling 和 InfluxDB 之间的连接。

在此先感谢您的帮助,我绝对需要它!

安东尼

我即将完成这篇文章,该文章展示了使用 Gatling、Grafana 和 InfluxDB(顺便说一句,没有单独安装 Graphite)创建整个监控基础设施所需的所有步骤,这对我来说非常有效。 我想几天后我会在 blazemeter.com 上的博客中发布它!所以请继续关注! http://blazemeter.com/blog

在那里你甚至会找到现成的解决方案来启动 Docker 中的所有内容。

但在此之前(如果您有急事),可以分享我的 InfluxDB 配置部分:

[[graphite]]
enabled = true
bind-address = ":2003"
database = "graphite"
retention-policy = ""
protocol = "tcp"
batch-size = 5000
batch-pending = 10
batch-timeout = "1s"
consistency-level = "one"
separator = "."
udp-read-buffer = 0

gatling.conf:

graphite {
  light = false              # only send the all* stats
  host = "localhost"         # The host where the Carbon server is located
  port = 2003                # The port to which the Carbon server listens to (2003 is default for plaintext, 2004 is default for pickle)
  protocol = "tcp"           # The protocol used to send data to Carbon (currently supported : "tcp", "udp")
  rootPathPrefix = "gatling" # The common prefix of all metrics sent to Graphite
  bufferSize = 8192          # GraphiteDataWriter's internal data buffer size, in bytes
  writeInterval = 1          # GraphiteDataWriter's write interval, in seconds
}

您需要检查的第一件事是 InfluxDB 实际上通过石墨协议接受传入指标。例如,在 InfluxDB 启动日志中,您应该找到这一行:

influxdb_1  | [I] 2018-01-26T13:40:37Z Listening on TCP: [::]:2003 service=graphite addr=:2003