I got non-standard information in K8s/Grafana log (see grafana-usage-report):
{"err":"Post \"https://stats.grafana.org/grafana-usage-report\": dial tcp 34.96.126.106:443: i/o timeout (Client.Timeout exceeded while awaiting headers)", "logger":"metrics", "lvl":"error", "msg":"Failed to send usage stats", "t":"2022-09-30T14:20:48.829643536Z"}
{"err":"Post \"https://stats.grafana.org/grafana-usage-report\": dial tcp 34.96.126.106:443: i/o timeout (Client.Timeout exceeded while awaiting headers)", "logger": "metrics", "lvl":"error","msg":"Failed to send usage stats", "t":"2022-10-01T14:20:53.032838369Z"}
{"err":"Post \"https://stats.grafana.org/grafana-usage-report\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)","logger":"metrics","lvl":"error","msg":"Failed to send usage stats", "t":"2022-10-02T14:20:55.4582491Z"}
{"err":"Post \"https://stats.grafana.org/grafana-usage-report\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)", "logger":"metrics","lvl": "error", "msg":"Failed to send usage stats", "t":"2022-10-03T14:21:00.4734810072"}
I checked useful comments under this question and I saw:
focus on config
log level
but it can have relation to Loki
But it is without progress on my side, right now (logs seems fine, debug level also, probably issue with Loki). Did you catch similar issue? How do you block sending these statistics on grafana/loki side?
BTW: Block communication in network level is easy, but I am looking for better/system solution.
I solved the issue based on these a few steps:
setup higher log detail
identify invalid content of grafana.ini file (based on coding, etc.)
finally I used reporting_enabled = false (it was the key point)
Related
I am using httpoison which uses Hackney under the hood to make HTTP requests.
By default, Hackney uses a default connection pool which is created with - connection timeout - 8000 ms, request timeout - 5000 ms. These numbers are too small for our project.
I have created a connection pool with different connection timeouts.
:hackney_pool.child_spec(:connection_pool, [timeout: 15_000, max_connections: 50])
and setting request timeout for each request like this
HTTPoison.get("httpbin.org/get", [], hackney: [recv_timeout: 15_000])
This does not look efficient to me as I need to put this timeout on every request.
I want to do set the recv_timeout at pool level eg:
:hackney_pool.child_spec(:connection_pool, [timeout: 15_000, recv_timeout: 15_000, max_connections: 50])
so when it creates a new connection, it can set the timeout at the connection level. My doubt is Can I specify the request timeout at the connection level? or is it just a request level timeout and HTTP does not support it at the connection level?.
I went to the documentation and found out these
# The time after which an idle connection will be automatically closed.
# Set to infinite to completely disable idle connection timeouts.
idle-timeout = 10 s
# Defines the default time period within which the application has to
# produce an HttpResponse for any given HttpRequest it received.
# The timeout begins to run when the *end* of the request has been
# received, so even potentially long uploads can have a short timeout.
# Set to `infinite` to completely disable request timeout checking.
#
# If this setting is not `infinite` the HTTP server layer attaches a
# `Timeout-Access` header to the request, which enables programmatic
# customization of the timeout period and timeout response for each
# request individually.
request-timeout = 20 s
I have a scenario where my server takes more than 10 seconds to process a response but before sending the HTTPResponse the TCP connection between the client and server is timed out because of idle timeout.
Although the connection is idle at the moment but the request is still processing.
I thought this was the responsibility of response timeout?
Can anyone in this context explain me the difference between idle-timeout and response-timeout?
Documentation is a bit confusing, I have run the experiments based on that :
idle-timeout: It is the max time a connection can sit idle. It behaves the same as the Request timeout. Example :
idle-timeout = 1 s
Application has sent a request to 3rd party API and connection established, But 3rd party is not responding back. Then you will get a Timeout exception.
"akka.stream.scaladsl.TcpIdleTimeoutException"
connecting-timeout: 500 ms. It indicates the maximum time (500 ms) in which an Http connection must be established.
From the documentation and more details here
# The idle timeout for an open connection after which it will be closed
# Set to null or "infinite" to disable the timeout, but notice that this
# is not encouraged since timeout are important mechanisms to protect your
# servers from malicious attacks or programming mistakes.
idleTimeout = 75 seconds
If looks like you are setting the idle timeout lower than the request timeout, so it takes precedence. Your idle timeout settings should be longer than the request timeout, so for each request, the request timeout decides when to close the connection.
I had a responsive Akka Http app, did some changes, then got these messages:
14:55:56.128 INFO bootstrap.akka.HttpActor - Accepted new connection from /127.0.0.1:55192
14:56:23.938 INFO bootstrap.akka.HttpActor - Accepted new connection from /127.0.0.1:55193
14:56:26.684 ERROR akka.actor.ActorSystemImpl - Internal server error, sending 500 response
akka.stream.impl.io.TcpStreamActor$$anonfun$handleSubscriptionTimeout$1$$anon$1: Publisher was not attached to upstream within deadline (5000) ms
14:56:26.684 ERROR akka.actor.ActorSystemImpl - Internal server error, sending 500 response
akka.stream.impl.io.TcpStreamActor$$anonfun$handleSubscriptionTimeout$1$$anon$1: Publisher was not attached to upstream within deadline (5000) ms
I cannot figure out what they mean. They are not mentioned in the docs and no Google hits. Could anyone share some insight?
akka.version=2.3.12
akka.stream.version=1.0
scala.version=2.11.6
jdk.version=1.8.0_60
In my src/main/resources/application.conf I include:
spray.can.server {
request-timeout = 1s
}
In order to test this, in the Future which is servicing my request I put a Thread.sleep(10000).
When I issue a request, the server waits 10 seconds and responds with no hint of a timeout being sent to the client.
I am not overriding the timeout handler.
Why are my clients (chrome and curl) not receiving a timeout?
The configuration looks correct, so Spray request timeout should be working. One of the frequent reasons for it not working is that your config application.conf is not being used by the application.
The reasons for config being ignored could be that it's in the wrong place, not included in your classpath, or not included in a JAR that you package.
To troubleshoot first check that default Spray timeout is working. By default it's 20 sec. Make your code sleep for 30sec and see if you get timeouts triggered.
Check what's in your final config values by printing it. Set this in your conf:
akka {
# Log the complete configuration at INFO level when the actor system is started.
# This is useful when you are uncertain of what configuration is used.
log-config-on-start = on
}
Finally, keep in mind other timeouts like timeout-timeout = 2 s.
I think the request-timeout is for the http client, if the response is not returned before that value, the client will get a timeout from spray, see the spary doc
# If a request hasn't been responded to after the time period set here
# a `spray.http.Timedout` message will be sent to the timeout handler.
# Set to `infinite` to completely disable request timeouts.
For example, in my web browser, I can got a below message:
Ooops! The server was not able to produce a timely response to your request.
Please try again in a short while!
If the timeout is long enough, the browser will keep waiting until a response is returned
I want to download the result of a Express.js REST API which is very slow to process (~10 minutes). I tried few timeout options with wget but it gives up after few minutes while I ask it to wait around ~60 000 years.
wget "http://localhost:5000/slowstuff" --http-user=user --http-password=password --read-timeout=1808080878708 --tries=1
--2015-02-26 11:14:21-- http://localhost:5000/slowstuff
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:5000... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Authentication selected: Basic realm="Authorization Required"
Reusing existing connection to [localhost]:5000.
HTTP request sent, awaiting response... No data received.
Giving up.
EDIT:
The problem doesn't come from the wget timeout value. With a timeout set to 4 seconds, the error is different: Read error (Connection timed out) in headers. And I have exactly the same problem with curl.
I think the problem comes from my API. It looks like a timeout of 2 minutes is set by default in NodeJS.
Now, I need to find how to change this value.
This
--http-password=password--read-timeout=1808080878708
is missing a blank. Use
--http-password=password --read-timeout=1808080878708