Added a generic HTTP logsink - #1063
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Adds a new generic HTTP log sink (
http) so osquery logs can be forwarded to any HTTP/HTTPS endpoint with configurable method, headers, format, and metadata wrapping. This is the twelfth sink type, joining Splunk, Graylog, Kafka, Kinesis, S3, Elastic, Logstash, DB, file, stdout, and none.Configuration
The sink exposes seven fields through the existing dynamic form schema (no new frontend component needed):
urlmethodPOSTPOSTorPUT)formatjsonjson(forward as-is),ndjson(one object per line),raw(bytes verbatim)contentTypeheaders{"Authorization":"Bearer xyz"}includeMetadatafalseenvironment,uuid,log_type,timestamptimeoutSeconds30Backend changes
Config (
pkg/config)loggers.go— newHTTPLoggerstruct with URL, method, headers (map[string]string), format, content type, timeout, and metadata toggle.types.go—LoggingHTTP = "http"constant;HTTP *HTTPLoggerfield added toYAMLConfigurationLogger.validation.go—LoggingHTTPregistered as a valid logging type.Exporter (
pkg/logging)http.go(new) —LoggerHTTPwith a pooledhttp.Client, configurable timeout, and three encoding modes:application/jsoncontent type.includeMetadatais true, each event is wrapped in anhttpEnvelopeadding environment, UUID, log type, and Unix timestamp.exporter_adapters.go—Name/IsEnabled/Exportmethods soLoggerHTTPsatisfies theDataExporterinterface.exporter_factory.go—config.LoggingHTTPcase inCreateExporter.Registry (
pkg/logsinks)logsinks.go— newconfig.LoggingHTTPentry inRegistrywith field specs for the dynamic form, aBuildfunc, and a customdecodeHTTPConfigdecoder that handlesheadersarriving as either a JSON object (API/YAML) or a JSON string (frontend single-line input). Seed path wired inconfigRowForType.logsinks_test.go—TestRegistryCoversAllYAMLTypesupdated to includehttp; added tests for registry presence, header decoding (object + string shapes), empty/null config, exporter build, and seed round-trip.Frontend changes
LogSinksPage.tsx— added an icon (arrow-up/upload pictogram) for thehttpsink type inSINK_TYPE_ICONS.Tests
pkg/logging/http_test.go(new) — 12 tests: defaults, nil config, JSON/NDJSON/raw formats, metadata envelopes (JSON + NDJSON), custom headers, PUT method, non-2xx response handling,Exportadapter,Closeidempotency.pkg/logsinks/logsinks_test.go— 6 new tests: registry entry, header decoding variants, empty config, exporter build, seed round-trip.pkg/config/validation_test.go—TestValidateTLSConfigValuesAcceptsHTTP.Validation
go build ./...— passgo test ./pkg/logging/... ./pkg/logsinks/... ./pkg/config/...— passgolangci-lint run— 0 issuesnpm run check(TypeScript) — passnpm test(415 frontend tests) — passmake openapi-check— no changes needed (sink types are served dynamically from the registry)