Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - type Connections
 - type HTTPRequests
 - type HealthChecks
 - type NginxClient
 - type NginxPlusClient
 - func (client *NginxPlusClient) AddHTTPServer(upstream string, server UpstreamServer) error
 - func (client *NginxPlusClient) AddStreamServer(upstream string, server StreamUpstreamServer) error
 - func (client *NginxPlusClient) CheckIfStreamUpstreamExists(upstream string) error
 - func (client *NginxPlusClient) CheckIfUpstreamExists(upstream string) error
 - func (client *NginxPlusClient) DeleteHTTPServer(upstream string, server string) error
 - func (client *NginxPlusClient) DeleteStreamServer(upstream string, server string) error
 - func (client *NginxPlusClient) GetHTTPServers(upstream string) ([]UpstreamServer, error)
 - func (client *NginxPlusClient) GetStats() (*Stats, error)
 - func (client *NginxPlusClient) GetStreamServers(upstream string) ([]StreamUpstreamServer, error)
 - func (client *NginxPlusClient) UpdateHTTPServers(upstream string, servers []UpstreamServer) ([]UpstreamServer, []UpstreamServer, error)
 - func (client *NginxPlusClient) UpdateStreamServers(upstream string, servers []StreamUpstreamServer) ([]StreamUpstreamServer, []StreamUpstreamServer, error)
 
- type Peer
 - type Queue
 - type Responses
 - type SSL
 - type ServerZone
 - type ServerZones
 - type Stats
 - type StreamUpstreamServer
 - type StubConnections
 - type StubStats
 - type Upstream
 - type UpstreamServer
 - type Upstreams
 
Constants ¶
const APIVersion = 2
    APIVersion is a version of NGINX Plus API.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connections ¶
Connections represents connection related stats.
type HTTPRequests ¶
HTTPRequests represents HTTP request related stats.
type HealthChecks ¶
type HealthChecks struct {
	Checks     uint64
	Fails      uint64
	Unhealthy  uint64
	LastPassed bool `json:"last_passed"`
}
    HealthChecks represents health check related stats for a peer.
type NginxClient ¶
type NginxClient struct {
	// contains filtered or unexported fields
}
    NginxClient allows you to fetch NGINX metrics from the stub_status page.
func NewNginxClient ¶
func NewNginxClient(httpClient *http.Client, apiEndpoint string) (*NginxClient, error)
NewNginxClient creates an NginxClient.
func (*NginxClient) GetStubStats ¶
func (client *NginxClient) GetStubStats() (*StubStats, error)
GetStubStats fetches the stub_status metrics.
type NginxPlusClient ¶
type NginxPlusClient struct {
	// contains filtered or unexported fields
}
    NginxPlusClient lets you add/remove servers to/from NGINX Plus via its API.
func NewNginxPlusClient ¶
func NewNginxPlusClient(httpClient *http.Client, apiEndpoint string) (*NginxPlusClient, error)
NewNginxPlusClient creates an NginxPlusClient.
func (*NginxPlusClient) AddHTTPServer ¶
func (client *NginxPlusClient) AddHTTPServer(upstream string, server UpstreamServer) error
AddHTTPServer adds the server to the upstream.
func (*NginxPlusClient) AddStreamServer ¶
func (client *NginxPlusClient) AddStreamServer(upstream string, server StreamUpstreamServer) error
AddStreamServer adds the server to the upstream.
func (*NginxPlusClient) CheckIfStreamUpstreamExists ¶
func (client *NginxPlusClient) CheckIfStreamUpstreamExists(upstream string) error
CheckIfStreamUpstreamExists checks if the stream upstream exists in NGINX. If the upstream doesn't exist, it returns the error.
func (*NginxPlusClient) CheckIfUpstreamExists ¶
func (client *NginxPlusClient) CheckIfUpstreamExists(upstream string) error
CheckIfUpstreamExists checks if the upstream exists in NGINX. If the upstream doesn't exist, it returns the error.
func (*NginxPlusClient) DeleteHTTPServer ¶
func (client *NginxPlusClient) DeleteHTTPServer(upstream string, server string) error
DeleteHTTPServer the server from the upstream.
func (*NginxPlusClient) DeleteStreamServer ¶
func (client *NginxPlusClient) DeleteStreamServer(upstream string, server string) error
DeleteStreamServer the server from the upstream.
func (*NginxPlusClient) GetHTTPServers ¶
func (client *NginxPlusClient) GetHTTPServers(upstream string) ([]UpstreamServer, error)
GetHTTPServers returns the servers of the upstream from NGINX.
func (*NginxPlusClient) GetStats ¶
func (client *NginxPlusClient) GetStats() (*Stats, error)
GetStats gets connection, request, ssl, zone, and upstream related stats from the NGINX Plus API.
func (*NginxPlusClient) GetStreamServers ¶
func (client *NginxPlusClient) GetStreamServers(upstream string) ([]StreamUpstreamServer, error)
GetStreamServers returns the stream servers of the upstream from NGINX.
func (*NginxPlusClient) UpdateHTTPServers ¶
func (client *NginxPlusClient) UpdateHTTPServers(upstream string, servers []UpstreamServer) ([]UpstreamServer, []UpstreamServer, error)
UpdateHTTPServers updates the servers of the upstream. Servers that are in the slice, but don't exist in NGINX will be added to NGINX. Servers that aren't in the slice, but exist in NGINX, will be removed from NGINX.
func (*NginxPlusClient) UpdateStreamServers ¶
func (client *NginxPlusClient) UpdateStreamServers(upstream string, servers []StreamUpstreamServer) ([]StreamUpstreamServer, []StreamUpstreamServer, error)
UpdateStreamServers updates the servers of the upstream. Servers that are in the slice, but don't exist in NGINX will be added to NGINX. Servers that aren't in the slice, but exist in NGINX, will be removed from NGINX.
type Peer ¶
type Peer struct {
	ID           int
	Server       string
	Service      string
	Name         string
	Backup       bool
	Weight       int
	State        string
	Active       uint64
	MaxConns     int `json:"max_conns"`
	Requests     uint64
	Responses    Responses
	Sent         uint64
	Received     uint64
	Fails        uint64
	HealthChecks HealthChecks `json:"health_checks"`
	Downtime     uint64
	Downstart    string
	Selected     string
	HeaderTime   uint64 `json:"header_time"`
	ResponseTime uint64 `json:"response_time"`
}
    Peer represents peer (upstream server) related stats.
type Responses ¶
type Responses struct {
	Responses1xx uint64 `json:"1xx"`
	Responses2xx uint64 `json:"2xx"`
	Responses3xx uint64 `json:"3xx"`
	Responses4xx uint64 `json:"4xx"`
	Responses5xx uint64 `json:"5xx"`
}
    Responses represents HTTP reponse related stats.
type SSL ¶
type SSL struct {
	Handshakes       uint64
	HandshakesFailed uint64 `json:"handshakes_failed"`
	SessionReuses    uint64 `json:"session_reuses"`
}
    SSL represents SSL related stats.
type ServerZone ¶
type ServerZone struct {
	Processing uint64
	Requests   uint64
	Responses  Responses
	Discarded  uint64
	Received   uint64
	Sent       uint64
}
    ServerZone represents server zone related stats.
type ServerZones ¶
type ServerZones map[string]ServerZone
ServerZones is map of server zone stats by zone name
type Stats ¶
type Stats struct {
	Connections  Connections
	HTTPRequests HTTPRequests
	SSL          SSL
	ServerZones  ServerZones
	Upstreams    Upstreams
}
    Stats represents NGINX Plus stats fetched from the NGINX Plus API. https://nginx.org/en/docs/http/ngx_http_api_module.html
type StreamUpstreamServer ¶
type StreamUpstreamServer struct {
	ID          int64  `json:"id,omitempty"`
	Server      string `json:"server"`
	MaxFails    int64  `json:"max_fails"`
	FailTimeout string `json:"fail_timeout,omitempty"`
	SlowStart   string `json:"slow_start,omitempty"`
}
    StreamUpstreamServer lets you configure Stream upstreams.
type StubConnections ¶
type StubConnections struct {
	Active   int64
	Accepted int64
	Handled  int64
	Reading  int64
	Writing  int64
	Waiting  int64
}
    StubConnections represents connections related metrics.
type StubStats ¶
type StubStats struct {
	Connections StubConnections
	Requests    int64
}
    StubStats represents NGINX stub_status metrics.