adds fake response for telegraph queries (#1130)

https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1124
This commit is contained in:
Nikolay 2021-03-15 22:10:47 +03:00 committed by Aliaksandr Valialkin
parent fc902734d9
commit a843dc0219
4 changed files with 24 additions and 4 deletions

View file

@ -515,6 +515,7 @@ See the docs at https://victoriametrics.github.io/vmagent.html .
-import.maxLineLen max_rows_per_line
The maximum length in bytes of a single line accepted by /api/v1/import; the line length can be limited with max_rows_per_line query arg passed to /api/v1/export
Supports the following optional suffixes for values: KB, MB, GB, KiB, MiB, GiB (default 104857600)
-influx.databasesNames comma separated names of influx database, that will be returned for /query and /influx/query request.
-influx.maxLineSize value
The maximum size in bytes for a single Influx line during parsing
Supports the following optional suffixes for values: KB, MB, GB, KiB, MiB, GiB (default 262144)

View file

@ -49,6 +49,7 @@ var (
dryRun = flag.Bool("dryRun", false, "Whether to check only config files without running vmagent. The following files are checked: "+
"-promscrape.config, -remoteWrite.relabelConfig, -remoteWrite.urlRelabelConfig . "+
"Unknown config entries are allowed in -promscrape.config by default. This can be changed with -promscrape.config.strictParse")
influxDatabasesNames = flag.String("influx.databasesNames", "_internal", "Comma separated names of databases, that will be returned for /query and /influx/query api.")
)
var (
@ -205,9 +206,17 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
return true
case "/query":
// Emulate fake response for influx query.
// This is required for TSBS benchmark.
// This is required for TSBS benchmark and some telegraph plugins.
influxQueryRequests.Inc()
fmt.Fprintf(w, `{"results":[{"series":[{"values":[]}]}]}`)
var dbs string
influxDbs := strings.Split(*influxDatabasesNames, ",")
for i := range influxDbs {
dbs += fmt.Sprintf(`"[%s]"`, influxDbs[i])
if i != len(influxDbs)-1 {
dbs += ","
}
}
fmt.Fprintf(w, `{"results":[{"name":"databases","columns":["name"],"series":[{"values":[%s]}]}]}`, dbs)
return true
case "/targets":
promscrapeTargetsRequests.Inc()

View file

@ -49,6 +49,7 @@ var (
httpListenAddr = flag.String("httpListenAddr", ":8480", "Address to listen for http connections")
maxLabelsPerTimeseries = flag.Int("maxLabelsPerTimeseries", 30, "The maximum number of labels accepted per time series. Superfluous labels are dropped")
storageNodes = flagutil.NewArray("storageNode", "Address of vmstorage nodes; usage: -storageNode=vmstorage-host1:8400 -storageNode=vmstorage-host2:8400")
influxDatabasesNames = flag.String("influx.databasesNames", "_internal", "Comma separated names of databases, that will be returned for /query and /influx/query api.")
)
var (
@ -215,9 +216,17 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
return true
case "influx/query":
// Emulate fake response for influx query.
// This is required for TSBS benchmark.
// This is required for TSBS benchmark and some telegraph plugins.
influxQueryRequests.Inc()
fmt.Fprintf(w, `{"results":[{"series":[{"values":[]}]}]}`)
var dbs string
influxDbs := strings.Split(*influxDatabasesNames, ",")
for i := range influxDbs {
dbs += fmt.Sprintf(`"[%s]"`, influxDbs[i])
if i != len(influxDbs)-1 {
dbs += ","
}
}
fmt.Fprintf(w, `{"results":[{"name":"databases","columns":["name"],"series":[{"values":[%s]}]}]}`, dbs)
return true
default:
// This is not our link

View file

@ -515,6 +515,7 @@ See the docs at https://victoriametrics.github.io/vmagent.html .
-import.maxLineLen max_rows_per_line
The maximum length in bytes of a single line accepted by /api/v1/import; the line length can be limited with max_rows_per_line query arg passed to /api/v1/export
Supports the following optional suffixes for values: KB, MB, GB, KiB, MiB, GiB (default 104857600)
-influx.databasesNames comma separated names of influx database, that will be returned for /query and /influx/query request.
-influx.maxLineSize value
The maximum size in bytes for a single Influx line during parsing
Supports the following optional suffixes for values: KB, MB, GB, KiB, MiB, GiB (default 262144)