From 95f46eb3ed5596974faeb06dbd72334f1aff8ad6 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Mon, 29 Jun 2020 07:52:35 -0500 Subject: [PATCH] api/agent: enable setting SuccessBeforePassing and FailuresBeforeCritical in API (#7949) Fixes #7764 Until now these two fields could only be set through on-disk agent configuration. This change adds the fields to the agent API struct definition so that they can be set using the agent HTTP API. --- api/agent.go | 42 ++++++++++++++------------ website/pages/api-docs/agent/check.mdx | 8 +++++ 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/api/agent.go b/api/agent.go index 3c5d1975f6..8e0ae5e507 100644 --- a/api/agent.go +++ b/api/agent.go @@ -196,26 +196,28 @@ type AgentCheckRegistration struct { // AgentServiceCheck is used to define a node or service level check type AgentServiceCheck struct { - CheckID string `json:",omitempty"` - Name string `json:",omitempty"` - Args []string `json:"ScriptArgs,omitempty"` - DockerContainerID string `json:",omitempty"` - Shell string `json:",omitempty"` // Only supported for Docker. - Interval string `json:",omitempty"` - Timeout string `json:",omitempty"` - TTL string `json:",omitempty"` - HTTP string `json:",omitempty"` - Header map[string][]string `json:",omitempty"` - Method string `json:",omitempty"` - Body string `json:",omitempty"` - TCP string `json:",omitempty"` - Status string `json:",omitempty"` - Notes string `json:",omitempty"` - TLSSkipVerify bool `json:",omitempty"` - GRPC string `json:",omitempty"` - GRPCUseTLS bool `json:",omitempty"` - AliasNode string `json:",omitempty"` - AliasService string `json:",omitempty"` + CheckID string `json:",omitempty"` + Name string `json:",omitempty"` + Args []string `json:"ScriptArgs,omitempty"` + DockerContainerID string `json:",omitempty"` + Shell string `json:",omitempty"` // Only supported for Docker. + Interval string `json:",omitempty"` + Timeout string `json:",omitempty"` + TTL string `json:",omitempty"` + HTTP string `json:",omitempty"` + Header map[string][]string `json:",omitempty"` + Method string `json:",omitempty"` + Body string `json:",omitempty"` + TCP string `json:",omitempty"` + Status string `json:",omitempty"` + Notes string `json:",omitempty"` + TLSSkipVerify bool `json:",omitempty"` + GRPC string `json:",omitempty"` + GRPCUseTLS bool `json:",omitempty"` + AliasNode string `json:",omitempty"` + AliasService string `json:",omitempty"` + SuccessBeforePassing int `json:",omitempty"` + FailuresBeforeCritical int `json:",omitempty"` // In Consul 0.7 and later, checks that are associated with a service // may also contain this optional DeregisterCriticalServiceAfter field, diff --git a/website/pages/api-docs/agent/check.mdx b/website/pages/api-docs/agent/check.mdx index 5976c1a1b5..af38eaf965 100644 --- a/website/pages/api-docs/agent/check.mdx +++ b/website/pages/api-docs/agent/check.mdx @@ -207,6 +207,14 @@ The table below shows this endpoint's support for - `Status` `(string: "")` - Specifies the initial status of the health check. +- `SuccessBeforePassing` `(int: 0)` - Specifies the number of consecutive successful + results required before check status transitions to passing. Available for HTTP, + TCP, gRPC, Docker & Monitor checks. + +- `FailuresBeforeCritical` `(int: 0)` - Specifies the number of consecutive unsuccessful + results required before check status transitions to critical. Available for HTTP, + TCP, gRPC, Docker & Monitor checks. + ### Sample Payload ```json