Documentation
¶
Overview ¶
SPDX-License-Identifier: GPL-3.0-or-later
Copyright (C) 2025 Aaron Mathis aaron.mathis@gmail.com
This file is part of GoSight.
GoSight is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GoSight is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GoSight. If not, see https://www.gnu.org/licenses/.
Model for container shared/model/container.go
Package model defines the data structures used in the GoSight application.
SPDX-License-Identifier: GPL-3.0-or-later
Copyright (C) 2025 Aaron Mathis aaron.mathis@gmail.com
This file is part of GoSight.
GoSight is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GoSight is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GoSight. If not, see https://www.gnu.org/licenses/.
Package model contains the data structures used in GoSight.
SPDX-License-Identifier: GPL-3.0-or-later
Copyright (C) 2025 Aaron Mathis aaron.mathis@gmail.com
This file is part of GoSight.
GoSight is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GoSight is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GoSight. If not, see https://www.gnu.org/licenses/.
Package model contains the data structures used in GoSight.
SPDX-License-Identifier: GPL-3.0-or-later
Copyright (C) 2025 Aaron Mathis aaron.mathis@gmail.com
This file is part of GoSight.
GoSight is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GoSight is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GoSight. If not, see https://www.gnu.org/licenses/.
Package model contains the data structures used in GoSight.
Index ¶
- func GenerateID() string
- type ActionRoute
- type ActionRouteSet
- type ActionSpec
- type Agent
- type AlertInstance
- type AlertQuery
- type AlertRule
- type AlertSummary
- type AnsibleCommandResult
- type CommandRequest
- type CommandResponse
- type CommandResult
- type Container
- type Endpoint
- type EventEntry
- type EventFilter
- type Expression
- type LogEntry
- type LogFilter
- type LogMeta
- type LogPayload
- type MatchCriteria
- type MatchFilter
- type Meta
- type Metric
- type MetricPayload
- type MetricPoint
- type MetricRow
- type MetricSelector
- type Options
- type Point
- type ProcessInfo
- type ProcessPayload
- type ProcessQueryFilter
- type ProcessSnapshot
- type Scope
- type ShellCommandResult
- type StatisticValues
- type StoredLog
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateID ¶
func GenerateID() string
Types ¶
type ActionRoute ¶
type ActionRoute struct {
ID string `yaml:"id" json:"id"`
Match MatchFilter `yaml:"match" json:"match"`
Actions []ActionSpec `yaml:"actions" json:"actions"`
}
ActionRoute defines a single action route for alerting. It includes a unique ID, a match filter to determine when the route should be triggered, and a list of actions to be executed when the route is matched.
type ActionRouteSet ¶
type ActionRouteSet struct {
Routes []ActionRoute `yaml:"routes" json:"routes"`
}
ActionRouteSet represents a set of action routes for alerting. It contains a list of ActionRoute objects, each defining a specific route for handling alerts based on matching criteria.
type ActionSpec ¶
type ActionSpec struct {
Type string `yaml:"type" json:"type"` // webhook, email, script
URL string `yaml:"url,omitempty"` // for webhook
Headers map[string]string `yaml:"headers,omitempty"`
Command string `yaml:"command,omitempty"` // for script
Args []string `yaml:"args,omitempty"` // optional args
}
ActionSpec defines the specifications for an action to be taken when an alert is triggered. It includes the type of action (e.g., webhook, email, script), the URL for webhooks, headers for the request, and the command to be executed for scripts.
type Agent ¶
type Agent struct {
AgentID string `json:"agent_id"`
HostID string `json:"host_id"`
Hostname string `json:"hostname"`
IP string `json:"ip"`
OS string `json:"os"`
Arch string `json:"arch"`
Version string `json:"version"`
Labels map[string]string `json:"labels"`
EndpointID string `json:"endpoint_id"` // Computed from HostID
LastSeen time.Time `json:"last_seen"`
Status string `json:"status"` // online/offline
Since string `json:"since"` // How long in current state
StartTime time.Time `json:"-"`
UptimeSeconds float64 `json:"uptime_seconds"`
Updated bool `json:"-"` // For in-memory use only
}
type AlertInstance ¶
type AlertInstance struct {
ID string `json:"id"`
RuleID string `json:"rule_id"`
EndpointID string `json:"endpoint_id,omitempty"`
State string `json:"state"` // "ok", "firing", "resolved", "no_data"
Previous string `json:"previous"` // previous state
Scope string `json:"scope"` // "global", "endpoint", "agent", "user", "cloud" etc
Target string `json:"target"` // e.g. "endpoint_id", "agent_id", "user_id"
FirstFired time.Time `json:"first_fired"` // when it first started firing
LastFired time.Time `json:"last_fired"` // when it last evaluated as firing
LastOK time.Time `json:"last_ok"` // last time condition returned OK
LastValue float64 `json:"last_value"` // most recent value
Level string `json:"level"` // from rule (info/warning/critical)
Message string `json:"message"` // expanded from template
Labels map[string]string `json:"labels"`
ResolvedAt *time.Time `json:"resolved_at,omitempty"` // when it was resolved
}
AlertInstance represents the current state of a triggered alert.
type AlertQuery ¶
type AlertRule ¶
type AlertRule struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Message string `json:"message" yaml:"message"` // message template for alert
Level string `json:"level" yaml:"level"` // info, warning, critical
Enabled bool `json:"enabled" yaml:"enabled"`
Type string `json:"type" yaml:"type"` // metric, log, event, composite
Match MatchCriteria `json:"match" yaml:"match"`
Scope Scope `json:"scope" yaml:"scope"`
Expression Expression `json:"expression" yaml:"expression"`
Actions []string `json:"actions" yaml:"actions"`
Options Options `json:"options" yaml:"options"`
}
AlertRule represents a rule for triggering alerts based on metrics.
type AlertSummary ¶
type AnsibleCommandResult ¶
type CommandRequest ¶
type CommandRequest struct {
AgentID string `json:"agent_id"` // Unique identifier for the agent
CommandType string `json:"command_type"` // e.g., "shell" or "ansible"
CommandData string `json:"command_data"` // The actual shell command or playbook content
Args []string `json:"args,omitempty"` // Optional arguments for shell commands
}
type CommandResponse ¶
type CommandResult ¶
type Endpoint ¶
type Endpoint struct {
EndpointID string `json:"endpoint_id"` // Computed from HostID
HostID string `json:"host_id"`
Hostname string `json:"hostname"`
ContainerName string `json:"container_name,omitempty"` // Only for containers
IP string `json:"ip"`
OS string `json:"os,omitempty"`
Arch string `json:"arch,omitempty"`
Version string `json:"version,omitempty"`
Labels map[string]string `json:"labels"`
ContainerID string `json:"container_id,omitempty"` // Only for containers
Name string `json:"name,omitempty"` // Only for containers
ImageName string `json:"image_name,omitempty"` // Only for containers
ImageID string `json:"image_id,omitempty"` // Only for containers
Runtime string `json:"runtime,omitempty"` // Only for containers
LastSeen time.Time `json:"last_seen"`
Status string `json:"status"` // online/offline
UptimeSeconds float64 `json:"uptime_seconds"`
Updated bool `json:"-"` // For in-memory use only
}
type EventEntry ¶
type EventEntry struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
Level string `json:"level"` // info, warning, critical
Type string `json:"type"` // event type (system / alert)
Category string `json:"category"` // metric, log, system, security
Message string `json:"message"`
Source string `json:"source"` // metric name, log source, etc.
Scope string `json:"scope"` // "endpoint", "system", etc.
Target string `json:"target"` // "host-123", "gosight-core", etc.
EndpointID string `json:"endpoint_id"`
Meta map[string]string `json:"meta"` // additional tags/labels
}
type EventFilter ¶
type Expression ¶
type LogEntry ¶
type LogEntry struct {
Timestamp time.Time `json:"timestamp"` // When the log was emitted
Level string `json:"level"` // info, warn, error, debug, etc.
Message string `json:"message"` // The actual log content
Source string `json:"source"` // Collector name or service name (e.g., journald, nginx)
Category string `json:"category"` // Optional: auth, network, system, app, etc.
PID int `json:"pid,omitempty"` // Process ID if available
Fields map[string]string `json:"fields"` // Structured fields (JSON logs, key/values)
Tags map[string]string `json:"tags"` // Custom labels/tags (user-defined or enriched)
Meta *LogMeta `json:"meta,omitempty"` // Optional platform/service-specific metadata
}
type LogFilter ¶
type LogFilter struct {
// Time range filter
Start time.Time // Filter logs from this time onward
End time.Time // Filter logs until this time
// Filtering by log properties
EndpointID string // Filter by endpoint ID (e.g., "host-123", "container-xyz")
Target string // Filter by target (e.g., "gosight-core", "host-123")
Level string // Filter by log level (e.g., "info", "warning", "error")
Category string // Filter by category (e.g., "system", "metric", "security")
Source string // Filter by source (e.g., "docker", "podman", "system")
Contains string // Filter by a substring match in the message
Unit string // Filter by systemd unit name (e.g., "nginx.service")
AppName string // Filter by application name (e.g., "nginx", "sshd")
Service string // For syslog/Windows Event Log
EventID string
User string
ContainerID string // if inside a container
Platform string
ContainerName string // Windows event ID, etc.
Meta map[string]string
Tags map[string]string // Additional tags to filter by
Extra map[string]string
Fields map[string]string // Additional fields to filter by
// Limit and sorting
Limit int // Max number of logs to return
Order string // Order direction: "asc" or "desc"
Cursor time.Time
Offset int
}
LogFilter is used to filter logs based on various criteria. It includes the limit of logs to return, the log levels to filter by, the unit of the logs, the source of the logs, a string to search for in the logs, and the start and end times for the logs.
type LogMeta ¶
type LogMeta struct {
Platform string `json:"platform,omitempty"` // journald, eventlog, syslog, etc.
AppName string `json:"app_name,omitempty"` // e.g., nginx, sshd
AppVersion string `json:"app_version,omitempty"` // if known
ContainerID string `json:"container_id,omitempty"` // if inside a container
ContainerName string `json:"container_name,omitempty"` // optional
Unit string `json:"unit,omitempty"` // For journald: systemd unit name
Service string `json:"service,omitempty"` // For syslog/Windows Event Log
EventID string `json:"event_id,omitempty"` // Windows event ID, etc.
User string `json:"user,omitempty"` // User associated with log entry
Executable string `json:"exe,omitempty"` // Path to binary if available
Path string `json:"path,omitempty"` // Original source log path
Extra map[string]string `json:"extra,omitempty"` // For collector-specific fields
}
type LogPayload ¶
type MatchCriteria ¶
type MatchCriteria struct {
EndpointIDs []string `json:"endpoint_ids,omitempty" yaml:"endpoint_ids,omitempty"`
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
Category string `json:"category,omitempty" yaml:"category,omitempty"`
Source string `json:"source,omitempty" yaml:"source,omitempty"`
Scope string `json:"scope,omitempty" yaml:"scope,omitempty"`
}
type MatchFilter ¶
type MatchFilter struct {
Level string `yaml:"level,omitempty" json:"level,omitempty"` // warning, critical, etc
RuleID string `yaml:"rule_id,omitempty" json:"rule_id,omitempty"` // specific rule
Tags map[string]string `yaml:"tags,omitempty" json:"tags,omitempty"` // meta.Tags match
}
MatchFilter defines the criteria for matching alerts.
type Meta ¶
type Meta struct {
// Agent Information
AgentID string `json:"agent_id"` // Unique ID for the agent
AgentVersion string `json:"agent_version"` // Version of the agent running
// General Host Information
HostID string `json:"host_id"` // Unique ID for the host
EndpointID string `json:"endpoint_id"` // Unique ID for the endpoint
Hostname string `json:"hostname"`
IPAddress string `json:"ip_address"`
OS string `json:"os,omitempty"`
OSVersion string `json:"os_version,omitempty"`
Platform string `json:"platform,omitempty"`
PlatformFamily string `json:"platform_family,omitempty"`
PlatformVersion string `json:"platform_version,omitempty"`
KernelArchitecture string `json:"kernel_architecture,omitempty"`
VirtualizationSystem string `json:"virtualization_system,omitempty"`
VirtualizationRole string `json:"virtualization_role,omitempty"`
KernelVersion string `json:"kernel_version,omitempty"`
Architecture string `json:"architecture,omitempty"`
// Cloud Provider Specific
CloudProvider string `json:"cloud_provider,omitempty"` // AWS, Azure, GCP
Region string `json:"region,omitempty"`
AvailabilityZone string `json:"availability_zone,omitempty"` // or Zone
InstanceID string `json:"instance_id,omitempty"`
InstanceType string `json:"instance_type,omitempty"`
AccountID string `json:"account_id,omitempty"`
ProjectID string `json:"project_id,omitempty"` // GCP
ResourceGroup string `json:"resource_group,omitempty"` //Azure
VPCID string `json:"vpc_id,omitempty"` // AWS, GCP
SubnetID string `json:"subnet_id,omitempty"` // AWS, GCP, Azure
ImageID string `json:"image_id,omitempty"` // AMI, Image, etc.
ServiceID string `json:"service_id,omitempty"` // if a managed service is the source
// Containerization/Orchestration
ContainerID string `json:"container_id,omitempty"`
ContainerName string `json:"container_name,omitempty"`
PodName string `json:"pod_name,omitempty"`
Namespace string `json:"namespace,omitempty"` // K8s namespace
ClusterName string `json:"cluster_name,omitempty"`
NodeName string `json:"node_name,omitempty"`
ContainerImageID string `json:"contianer_image_id,omitempty"` // Docker image ID
ContainerImageName string `json:"image_name,omitempty"` // Docker image name
// Application Specific
Application string `json:"application,omitempty"`
Environment string `json:"environment,omitempty"` // dev, staging, prod
Service string `json:"service,omitempty"` // if a microservice
Version string `json:"version,omitempty"`
DeploymentID string `json:"deployment_id,omitempty"`
// Network Information
PublicIP string `json:"public_ip,omitempty"`
PrivateIP string `json:"private_ip,omitempty"`
MACAddress string `json:"mac_address,omitempty"`
NetworkInterface string `json:"network_interface,omitempty"`
// Custom Metadata
Tags map[string]string `json:"tags,omitempty"` // Allow for arbitrary key-value pairs
}
type Metric ¶
type Metric struct {
Namespace string `json:"namespace,omitempty"`
SubNamespace string `json:"subnamespace,omitempty"`
Name string `json:"name"`
Timestamp time.Time `json:"timestamp"`
Value float64 `json:"value"`
StatisticValues *StatisticValues `json:"stats"`
Unit string `json:"unit,omitempty"`
Dimensions map[string]string `json:"dimensions,omitempty"`
StorageResolution int `json:"resolution,omitempty"`
Type string `json:"type,omitempty"`
}
type MetricPayload ¶
type MetricPoint ¶
type MetricSelector ¶
type Options ¶
type Options struct {
Cooldown string `json:"cooldown,omitempty" yaml:"cooldown,omitempty"`
EvalInterval string `json:"eval_interval,omitempty" yaml:"eval_interval,omitempty"`
RepeatInterval string `json:"repeat_interval,omitempty" yaml:"repeat_interval,omitempty"`
NotifyOnResolve bool `json:"notify_on_resolve,omitempty" yaml:"notify_on_resolve,omitempty"`
}
type ProcessInfo ¶
type ProcessInfo struct {
PID int `json:"pid"`
PPID int `json:"ppid"`
User string `json:"user"`
Executable string `json:"exe"`
Cmdline string `json:"cmdline"`
CPUPercent float64 `json:"cpu_percent"`
MemPercent float64 `json:"mem_percent"`
Threads int `json:"threads"`
StartTime time.Time `json:"start_time"`
Tags map[string]string `json:"tags,omitempty"` // container_id, container_name, etc
}
ProcessInfo represents information about a single process.
type ProcessPayload ¶
type ProcessQueryFilter ¶
type ProcessSnapshot ¶
type ProcessSnapshot struct {
Timestamp time.Time `json:"timestamp"`
HostID string `json:"host_id"`
EndpointID string `json:"endpoint_id"`
Processes []ProcessInfo `json:"processes"`
Meta *Meta `json:"meta"` // Same as metric/log meta
}
ProcessSnapshot represents a snapshot of processes running on a host at a specific time.
type ShellCommandResult ¶
type ShellCommandResult struct {
Output string // Full stdout and stderr combined
ExitCode int // Actual exit code (0 = success)
ErrorMessage string // Error description if command failed (e.g. exec errors)
Duration time.Duration // How long it took to run
StartedAt time.Time // Optional: when the command started
}
type StatisticValues ¶
type StatisticValues struct {
Minimum float64 `json:"min"`
Maximum float64 `json:"max"`
SampleCount int `json:"count"`
Sum float64 `json:"sum"`
}
StatisticValues represents the minimum, maximum, count, and sum of a metric.