influx-proxy icon indicating copy to clipboard operation
influx-proxy copied to clipboard

请问 我启动了influx-proxy,但是query返回错误,write没有数据

Open 237657425 opened this issue 6 years ago • 8 comments

write: 虽然返回204成功,但是2个influxdb库里并没有数据 [root@localhost ~]# curl -i -XPOST 'http://20.21.1.129:6666/write?db=sanchen' --data-binary 'cpu_load_short2,host=server01,region=us-west value=0.64 1539825713536000000' HTTP/1.1 204 No Content X-Influxdb-Version: 1.1 Date: Fri, 26 Oct 2018 01:47:06 GMT

query: 返回fobbideon [root@localhost ~]# curl -v -G "http://20.21.1.129:6666/query?db=sanchen&u=root&p=1qaz@WSX" --data-urlencode "q=select * from cpu_load_short "

  • About to connect() to 20.21.1.129 port 6666 (#0)
  • Trying 20.21.1.129...
  • Connected to 20.21.1.129 (20.21.1.129) port 6666 (#0)

GET /query?db=sanchen&u=root&p=1qaz@WSX&q=select%20%2A%20from%20cpu_load_short%20 HTTP/1.1 User-Agent: curl/7.29.0 Host: 20.21.1.129:6666 Accept: /

< HTTP/1.1 400 Bad Request < X-Influxdb-Version: 1.1 < Date: Fri, 26 Oct 2018 01:48:43 GMT < Content-Length: 15 < Content-Type: text/plain; charset=utf-8 <

  • Connection #0 to host 20.21.1.129 left intact query forbidden

问下该怎么解决

237657425 avatar Oct 26 '18 01:10 237657425

首先明确一点。proxy是在数据校验OK后直接返回成功的,其间并不保证数据向后写入是否正确。数据写入需要看proxy自身向后的刷写是否成功。你可以看一下proxy的日志,看看向后写入是否成功,还是有什么问题。

shell909090 avatar Oct 26 '18 06:10 shell909090

另外,注意到你的请求返回错误是400,而不是无数据。我现在记得不是很清楚,但是400这个错误并不是无数据,而是你的请求本身并不被接纳的结果。你可以试试直接query目标看看。

shell909090 avatar Oct 26 '18 06:10 shell909090

@shell909090 我现在把2台测试机的influxdb 身份认证关闭 写入的话,但只有主节点有数据,次节点没有数据。 query则还是不行 2018/10/26 14:54:40.888432 config.go:138: 2 backends loaded from redis. 2018/10/26 14:54:40.888542 file.go:208: read meta error: EOF 2018/10/26 14:54:40.888590 file.go:208: read meta error: EOF 2018/10/26 14:54:40.890093 config.go:196: 3 measurements loaded from redis. 2018/10/26 14:54:40.890179 http.go:29: http database: sanchen 2018/10/26 14:54:40.890261 main.go:107: http service start. 2018/10/26 14:57:10.109881 http.go:86: query error: query forbidden,the query is select * from cpu_load_short where time >='2018-07-16T10:00:00Z' tz('Asia/Shanghai'),the client is 20.21.1.129:59052 2018/10/26 15:07:49.278526 http.go:86: query error: query forbidden,the query is select * from cpu_load_short where time >='2018-07-16T10:00:00Z' tz('Asia/Shanghai'),the client is 20.21.1.129:60034

237657425 avatar Oct 26 '18 07:10 237657425

BACKENDS = { 'local': { 'url': 'http://20.21.1.129:8086', 'db': 'sanchen', 'zone':'local', 'interval': 1000, 'timeout': 10000, 'timeoutquery':600000, 'maxrowlimit':10000,
'checkinterval':1000, 'rewriteinterval':10000, }, 'local2': { 'url': 'http://20.21.1.130:8086', 'db': 'sanchen', 'interval': 200, }, }

KEYMAPS = { 'cpu': ['local'], 'temperature': ['local2'], 'default': ['local'] }

NODES = { 'l1': { 'listenaddr': ':6666', 'db': 'sanchen', 'zone': 'local', 'interval':10, 'idletimeout':10, 'writetracing':0, 'querytracing':0, } }

DEFAULT_NODE = { 'listenaddr': ':6666' } 这是核心的配置 curl -i -XPOST 'http://20.21.1.129:6666/write?db=sanchen' --data-binary 'test_proxy,host=server01,region=us-west value=0.64 1539825713536000000' write只有239的节点上有数据,130节点还是没有

237657425 avatar Oct 26 '18 07:10 237657425

你的这个配置和你的写入对不起来,CPU的写入明显是映射到local,没有local2。写入的时候当然只有主节点有数据。至于test_proxy这个数据,如果你用最新版本的话,默认的配置是_default_而不是default。因此根本无法写入。

查询失败是因为query forbidden,估计是因为查询中不带时间。我们默认禁止这样的查询,因为这个会消耗巨量的CPU资源。具体可以看这个文件。其中SupportCmds是必须保持部分,如果无法带有其中之一,则查询被禁用。

https://github.com/shell909090/influx-proxy/blob/master/backend/commands.go

这一功能可以禁用以下代码关闭。

https://github.com/shell909090/influx-proxy/blob/master/backend/cluster.go#L383

shell909090 avatar Oct 26 '18 08:10 shell909090

现在 入库是没有问题了 但是query还是不行 curl -i -G "http://20.21.1.129:6666/query?db=sanchen" --data-urlencode "q=select * from cpu_load_short where time >='2018-07-16T10:00:00Z' tz('Asia/Shanghai')" 这个sql 带有time查询的

237657425 avatar Oct 26 '18 09:10 237657425

您好,您的查询不符合influxdb标准,请使用influxdb客户端,或者根据标准修正格式。

https://docs.influxdata.com/influxdb/v1.6/query_language/spec/

shell909090 avatar Oct 26 '18 12:10 shell909090

@237657425 我的问题感觉和你这个比较相似,请问是怎么解决的...

www6223166 avatar May 28 '19 04:05 www6223166