Skip to content

Commit

Permalink
add nomad.agent.http.exceeded metric
Browse files Browse the repository at this point in the history
Count of HTTP connections exceeding concurrency limit.
  • Loading branch information
wjordan committed Jul 15, 2022
1 parent 3372c07 commit 9768e42
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions command/agent/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/armon/go-metrics"
"golang.org/x/time/rate"
"net"
"net/http"
Expand Down Expand Up @@ -278,6 +279,7 @@ func connLimiter(connLimit int, logger log.Logger) func(conn net.Conn, state htt
MaxConnsPerClientIP: connLimit,
}).HTTPConnStateFuncWithErrorHandler(func(err error, conn net.Conn) {
if err == connlimit.ErrPerClientIPLimitReached {
metrics.IncrCounter([]string{"nomad", "agent", "http", "exceeded"}, 1)
if n := limiter.Reserve(); n.Delay() == 0 {
logger.Warn("Too many concurrent connections", "address", conn.RemoteAddr().String(), "limit", connLimit)
conn.SetDeadline(time.Now().Add(10 * time.Millisecond))
Expand Down
8 changes: 8 additions & 0 deletions website/content/docs/operations/metrics-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,14 @@ Raft database metrics are emitted by the `raft-boltdb` library.
| `nomad.raft.boltdb.txstats.write` | Count of total write operations | Integer | Counter |
| `nomad.raft.boltdb.txstats.writeTime` | Sample of write operation times | Nanoseconds | Summary |

## Agent Metrics

Agent metrics are emitted by all Nomad agents running in either client or server mode.

| Metric | Description | Unit | Type |
| ----------------------------------------- | ----------------------------------------------------- | ----------- | ------- |
| `nomad.agent.http.exceeded` | Count of HTTP connections exceeding concurrency limit | Integer | Counter |

[tagged-metrics]: /docs/telemetry/metrics#tagged-metrics
[s_port_plan_failure]: /s/port-plan-failure

Expand Down

0 comments on commit 9768e42

Please sign in to comment.