Hi devs, need to implement logging (just send as push, dont wait response) to influxdb (OSS v2.7) using async php swoole client through http2.0,
for this I try to use inputs.influxdb_v2_listener as listener for async http2.0 client,
but I see that force http2 not work
curl --http2-prior-knowledge -X POST “http://localhost:8186/api/v2/write”
curl: (52) Empty reply from server
(curl --http2 -X POST “http://localhost:8186/api/v2/write” - this work fine)
swoole & telegraf processes in same docker container locally.
Nothing like telegraf error in logs, but in influx didnt see msg send through http2.0.
Did not see in docs is http2.0 supported by telegraf.
Also did not see in docs is http2.0 supported by influx (HTTP/2 support · Issue #15903 · influxdata/influxdb · GitHub)
So question is it possible to have sending chain (async http2.0 client + telegraf + influx) on http2.0?
(swoole http client work fine)
define('LOG_SERVER_HOST', '127.0.0.1');
define('TELEGRAF_LISTENER_PORT', 8186);
function logMessage(string $case, string $message, string $type = 'INFO')
{
$timestamp = intval(microtime(true) * 1000000000); //ns with ms
$logEntry = "swoole_logs,case=$case,type=$type message=\"$message\" $timestamp";
#through Coroutine Http2 Client
//https://openswoole.com/docs/modules/swoole-coroutine-http2-client
//OpenSwoole with support of Http2
$client = new OpenSwoole\Coroutine\Http2\Client(LOG_SERVER_HOST, TELEGRAF_LISTENER_PORT);
if (!$client->connect()) {
error_log("Failed to connect to InfluxDB v2 listener");
return;
}
$Request = new OpenSwoole\Http2\Request();
$Request->method = "POST";
$Request->path = "/api/v2/write";
$Request->headers = [
'host' => 'localhost',
'Content-Length' => strlen($logEntry),
'Content-Type' => 'text/plain',
'Connection' => 'close',
];
$Request->data = $logEntry;
$Request->pipeline = false;
$client->send($Request);
$client->close();
}
telegraf.conf
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
debug = true
quiet = false
logtarget = "stderr"
[[inputs.influxdb_v2_listener]]
service_address = "127.0.0.1:8186"
parser_type = "internal"
data_format = "influx"
[[outputs.influxdb_v2]]
urls = ["http://influxdb:8086"]
token = "token"
organization = "ORG"
bucket = "LOGS"
# HTTP/2 Timeouts
# The following values control the HTTP/2 client's timeouts. These settings
# are generally not required unless a user is seeing issues with client
# disconnects. If a user does see issues, then it is suggested to set these
# values to "15s" for ping timeout and "30s" for read idle timeout and
# retry.
#
# Note that the timer for read_idle_timeout begins at the end of the last
# successful write and not at the beginning of the next write.
ping_timeout = "15s"
read_idle_timeout = "30s"