http_response

package
v0.0.0-...-5655933 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 17 Imported by: 0

README

http_response

HTTP 探测插件,用于检测 HTTP 地址的连通性、延迟、HTTPS证书过期时间

code meanings

Success          = 0
ConnectionFailed = 1
Timeout          = 2
DNSError         = 3
AddressError     = 4
BodyMismatch     = 5
CodeMismatch     = 6

Configuration

最核心的配置就是 targets 配置,配置目标地址,比如想要监控两个地址:

[[instances]]
targets = [
    "http://localhost:8080",
    "https://www.baidu.com"
]

instances 下面的所有 targets 共享同一个 [[instances]] 下面的配置,比如超时时间,HTTP方法等,如果有些配置不同,可以拆成多个不同的 [[instances]],比如:

[[instances]]
targets = [
    "http://localhost:8080",
    "https://www.baidu.com"
]
method = "GET"

[[instances]]
targets = [
    "http://localhost:9090"
]
method = "POST"

监控大盘和告警规则

该 README 的同级目录下,提供了 dashboard.json 就是监控大盘的配置,alerts.json 是告警规则,可以导入夜莺使用。

Documentation

Index

Constants

View Source
const (
	Success          uint64 = 0
	ConnectionFailed uint64 = 1
	Timeout          uint64 = 2
	DNSError         uint64 = 3
	AddressError     uint64 = 4
	BodyMismatch     uint64 = 5
	CodeMismatch     uint64 = 6
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPResponse

type HTTPResponse struct {
	config.PluginConfig
	Instances []*Instance `toml:"instances"`

	Mappings map[string]map[string]string `toml:"mappings"`
}

func (*HTTPResponse) Clone

func (h *HTTPResponse) Clone() inputs.Input

func (*HTTPResponse) GetInstances

func (h *HTTPResponse) GetInstances() []inputs.Instance

func (*HTTPResponse) Name

func (h *HTTPResponse) Name() string

type Instance

type Instance struct {
	config.InstanceConfig

	Targets                         []string        `toml:"targets"`
	Interface                       string          `toml:"interface"`
	ResponseTimeout                 config.Duration `toml:"response_timeout"`
	Headers                         []string        `toml:"headers"`
	Body                            string          `toml:"body"`
	ExpectResponseSubstring         string          `toml:"expect_response_substring"`
	ExpectResponseRegularExpression string          `toml:"expect_response_regular_expression"`
	ExpectResponseStatusCode        *int            `toml:"expect_response_status_code"`
	ExpectResponseStatusCodes       string          `toml:"expect_response_status_codes"`
	config.HTTPProxy

	config.HTTPCommonConfig

	// Mappings Set the mapping of extra tags in batches
	Mappings map[string]map[string]string `toml:"mappings"`
	// contains filtered or unexported fields
}

func (*Instance) Gather

func (ins *Instance) Gather(slist *types.SampleList)

func (*Instance) Init

func (ins *Instance) Init() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL