Documentation ¶
Overview ¶
Package http implements the HTTP service.
Index ¶
- Constants
- func ServeSupportBundle(rw http.ResponseWriter, b *Bundle, logsBuf *bytes.Buffer) error
- type Arguments
- type Bundle
- type ClientAuth
- type Component
- type Data
- type Metadata
- type Options
- type Service
- type ServiceHandler
- type SupportBundleContext
- type TLSArguments
- type TLSCipher
- type TLSCurve
- type TLSVersion
- type WindowsCertificateFilter
- type WindowsClientFilter
- type WindowsServerFilter
Constants ¶
const ServiceName = "http"
ServiceName defines the name used for the HTTP service.
Variables ¶
This section is empty.
Functions ¶
func ServeSupportBundle ¶ added in v1.5.0
ServeSupportBundle the collected data and logs as a zip file over the given http.ResponseWriter.
Types ¶
type Arguments ¶
type Arguments struct {
TLS *TLSArguments `alloy:"tls,block,optional"`
}
Arguments holds runtime settings for the HTTP service.
type Bundle ¶ added in v1.5.0
type Bundle struct {
// contains filtered or unexported fields
}
Bundle collects all the data that is exposed as a support bundle.
func ExportSupportBundle ¶ added in v1.5.0
func ExportSupportBundle(ctx context.Context, runtimeFlags []string, srvAddress string, dialContext server.DialContextFunc) (*Bundle, error)
ExportSupportBundle gathers the information required for the support bundle.
type ClientAuth ¶
type ClientAuth tls.ClientAuthType
ClientAuth configures the type of TLS client authentication to use.
func (ClientAuth) MarshalText ¶
func (c ClientAuth) MarshalText() ([]byte, error)
MarshalText marshals the ID of a client auth type to its name.
func (*ClientAuth) UnmarshalText ¶
func (c *ClientAuth) UnmarshalText(text []byte) error
UnmarshalText unmarshals the name of a client auth type to its ID.
type Component ¶
type Component interface { component.Component // Handler should return a valid HTTP handler for the component. // All requests to the component will have the path trimmed such that the component is at the root. // For example, f a request is made to `/component/{id}/metrics`, the component // will receive a request to just `/metrics`. Handler() http.Handler }
Component is a component which also contains a custom HTTP handler.
type Data ¶
type Data struct { // Address that the HTTP service is configured to listen on. HTTPListenAddr string // Address that the HTTP service is configured to listen on for in-memory // traffic when [DialFunc] is used to establish a connection. MemoryListenAddr string // BaseHTTPPath is the base path where component HTTP routes are exposed. BaseHTTPPath string // DialFunc is a function which establishes in-memory network connection when // address is MemoryListenAddr. If address is not MemoryListenAddr, DialFunc // establishes an outbound network connection. DialFunc func(ctx context.Context, network, address string) (net.Conn, error) }
Data includes information associated with the HTTP service.
func (Data) HTTPPathForComponent ¶
HTTPPathForComponent returns the full HTTP path for a given global component ID.
type Metadata ¶ added in v1.5.0
type Metadata struct { BuildVersion string `yaml:"build_version"` OS string `yaml:"os"` Architecture string `yaml:"architecture"` Uptime float64 `yaml:"uptime"` }
Metadata contains general runtime information about the current Alloy environment.
type Options ¶
type Options struct { Logger *logging.Logger // Where to send logs. Tracer trace.TracerProvider // Where to send traces. Gatherer prometheus.Gatherer // Where to collect metrics from. ReadyFunc func() bool ReloadFunc func() (*alloy_runtime.Source, error) HTTPListenAddr string // Address to listen for HTTP traffic on. MemoryListenAddr string // Address to accept in-memory traffic on. EnablePProf bool // Whether pprof endpoints should be exposed. MinStability featuregate.Stability // Minimum stability level to utilize for feature gates BundleContext SupportBundleContext // Context for delivering a support bundle }
Options are used to configure the HTTP service. Options are constant for the lifetime of the HTTP service.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) Data ¶
Data returns an instance of Data. Calls to Data are cachable by the caller.
Data must only be called after parsing command-line flags.
func (*Service) Definition ¶
func (s *Service) Definition() service.Definition
Definition returns the definition of the HTTP service.
type ServiceHandler ¶
type ServiceHandler interface { service.Service // ServiceHandler returns the base route and HTTP handlers to register for // the provided service. // // This method is only called for services that declare a dependency on // the http service. // // The http service prioritizes longer base routes. Given two base routes of // /foo and /foo/bar, an HTTP URL of /foo/bar/baz will be routed to the // longer base route (/foo/bar). ServiceHandler(host service.Host) (base string, handler http.Handler) }
ServiceHandler is a Service which exposes custom HTTP handlers.
type SupportBundleContext ¶ added in v1.5.0
type SupportBundleContext struct { DisableSupportBundle bool // Whether support bundle endpoint should be disabled. RuntimeFlags []string // Alloy runtime flags to send with support bundle }
SupportBundleContext groups the relevant context that is used in the HTTP service config for the support bundle
type TLSArguments ¶
type TLSArguments struct { Cert string `alloy:"cert_pem,attr,optional"` CertFile string `alloy:"cert_file,attr,optional"` Key alloytypes.Secret `alloy:"key_pem,attr,optional"` KeyFile string `alloy:"key_file,attr,optional"` ClientCA string `alloy:"client_ca_pem,attr,optional"` ClientCAFile string `alloy:"client_ca_file,attr,optional"` ClientAuth ClientAuth `alloy:"client_auth_type,attr,optional"` CipherSuites []TLSCipher `alloy:"cipher_suites,attr,optional"` CurvePreferences []TLSCurve `alloy:"curve_preferences,attr,optional"` MinVersion TLSVersion `alloy:"min_version,attr,optional"` MaxVersion TLSVersion `alloy:"max_version,attr,optional"` // Windows Certificate Filter WindowsFilter *WindowsCertificateFilter `alloy:"windows_certificate_filter,block,optional"` }
TLSArguments configures TLS settings for the HTTP service.
func (*TLSArguments) Validate ¶
func (args *TLSArguments) Validate() error
Validate returns whether args is valid.
type TLSCipher ¶
type TLSCipher uint16
TLSCipher holds the ID of a TLS cipher suite.
func (TLSCipher) MarshalText ¶
MarshalText marshals the ID of a cipher suite to its name.
func (*TLSCipher) UnmarshalText ¶
UnmarshalText unmarshals the name of a cipher suite to its ID.
type TLSCurve ¶
TLSCurve holds the ID of a tls.CurveID.
func (TLSCurve) MarshalText ¶
MarshalText marshals the ID of a curve to its name.
func (*TLSCurve) UnmarshalText ¶
UnmarshalText unmarshals the name of a curve to its ID.
type TLSVersion ¶
type TLSVersion uint16
TLSVersion holds the ID of a TLS version.
func (TLSVersion) MarshalText ¶
func (v TLSVersion) MarshalText() ([]byte, error)
MarshalText marshals the ID of a TLS version to its name.
func (*TLSVersion) UnmarshalText ¶
func (v *TLSVersion) UnmarshalText(text []byte) error
UnmarshalText unmarshals the name of a TLS version to its ID.
type WindowsCertificateFilter ¶
type WindowsCertificateFilter struct { Server *WindowsServerFilter `alloy:"server,block"` Client *WindowsClientFilter `alloy:"client,block"` }
WindowsCertificateFilter represents the configuration for accessing the Windows store
type WindowsClientFilter ¶
type WindowsClientFilter struct { IssuerCommonNames []string `alloy:"issuer_common_names,attr,optional"` SubjectRegEx string `alloy:"subject_regex,attr,optional"` TemplateID string `alloy:"template_id,attr,optional"` }
WindowsClientFilter is used to select a client root CA certificate
type WindowsServerFilter ¶
type WindowsServerFilter struct { Store string `alloy:"store,attr,optional"` SystemStore string `alloy:"system_store,attr,optional"` IssuerCommonNames []string `alloy:"issuer_common_names,attr,optional"` TemplateID string `alloy:"template_id,attr,optional"` RefreshInterval time.Duration `alloy:"refresh_interval,attr,optional"` }
WindowsServerFilter is used to select a server certificate
func (*WindowsServerFilter) SetToDefault ¶
func (wcf *WindowsServerFilter) SetToDefault()
SetToDefault sets the default for WindowsServerFilter