Skip to content
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c5deb61
feat: add syslog receiver
RRashmit Nov 13, 2024
0162757
chore: update port to non priviledged
RRashmit Nov 13, 2024
036aba9
chore: update the syslog type and template
RRashmit Nov 18, 2024
0e138e7
chore: update comments
RRashmit Nov 18, 2024
4f6db4a
chore: update the docker
RRashmit Nov 18, 2024
409242c
chore: updated the otel collector pipeline
RRashmit Nov 25, 2024
3fde54c
chore: update multiple syslog servers
RRashmit Nov 25, 2024
45bb8ee
Merge branch 'v3' into poc-v3-otel-syslog
dhurley Nov 27, 2024
7ddc9b8
Replace syslog receiver with tcplog receiver
dhurley Nov 28, 2024
1b7a359
Replace syslog receiver with tcplog receiver
dhurley Nov 28, 2024
6f0edde
Replace syslog receiver with tcplog receiver
dhurley Nov 28, 2024
5faae62
Replace syslog receiver with tcplog receiver
dhurley Nov 28, 2024
bbc3eb5
Replace syslog receiver with tcplog receiver
dhurley Nov 28, 2024
29e07a0
Merge branch 'v3' into poc-v3-otel-syslog
dhurley Dec 2, 2024
f3b0636
Visualize NAP logs in mock collector grafana
dhurley Dec 2, 2024
2597fd6
Visualize NAP logs in mock collector grafana
dhurley Dec 2, 2024
079d594
Visualize NAP logs in mock collector grafana
dhurley Dec 3, 2024
ddb02df
Remove key_value_parser operator
dhurley Dec 3, 2024
4f9f42a
Merge branch 'poc-v3-otel-syslog' into chore/add-nap-to-mock-collector
dhurley Dec 3, 2024
5d0f9b0
Update tcplog timestamp operator
dhurley Dec 4, 2024
653c907
Merge branch 'poc-v3-otel-syslog' into chore/add-nap-to-mock-collector
dhurley Dec 4, 2024
a24ce79
Add NGINX App Protect instance type
dhurley Dec 6, 2024
a65e3d3
Update NGINX plus dockerfile to always build with platform set to amd…
dhurley Dec 17, 2024
771a1cf
Update how long to wait for nginx master process to start in dockerfile
dhurley Dec 20, 2024
dc26a5d
Merge branch 'v3' into chore/add-nap-to-mock-collector
dhurley Dec 20, 2024
f41b499
Merge branch 'chore/add-nap-to-mock-collector' into chore/report-nap-…
dhurley Dec 20, 2024
b8bd1b3
Fix OSARCH variable in Makefile
dhurley Dec 20, 2024
1593c26
Fix OSARCH variable in Makefile
dhurley Dec 20, 2024
29f338e
Update README
dhurley Jan 7, 2025
4413e5e
Fix makefile target
dhurley Jan 9, 2025
c5dd646
Clean up
dhurley Jan 17, 2025
2307225
Merge branch 'chore/add-nap-to-mock-collector' into chore/report-nap-…
dhurley Jan 22, 2025
975cdd3
Make config path optional and make metrics optional in OTel collector
dhurley Jan 24, 2025
5cc2544
Merge branch 'v3' into chore/report-nap-instances
dhurley Feb 10, 2025
ae498fc
Update how NGINX & NAP processes are discovered
dhurley Feb 13, 2025
fa92bdd
Update protos
dhurley Feb 14, 2025
5b3a23a
Update process operator
dhurley Feb 14, 2025
10ab393
Merge branch 'v3' into chore/report-nap-instances
dhurley Feb 14, 2025
b4f1451
Merge branch 'v3' into chore/report-nap-instances
dhurley Mar 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
504 changes: 306 additions & 198 deletions api/grpc/mpi/v1/command.pb.go

Large diffs are not rendered by default.

149 changes: 149 additions & 0 deletions api/grpc/mpi/v1/command.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion api/grpc/mpi/v1/command.proto
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ message InstanceMeta {
INSTANCE_TYPE_NGINX_PLUS = 3;
// NGINX Unit
INSTANCE_TYPE_UNIT = 4;
// NGINX App Protect
INSTANCE_TYPE_NGINX_APP_PROTECT = 5;
}
// the types of instances possible
InstanceType instance_type = 2;
Expand All @@ -296,13 +298,15 @@ message InstanceRuntime {
// the binary path location
string binary_path = 2 [(buf.validate.field).string.prefix = "/"];
// the config path location
string config_path = 3 [(buf.validate.field).string.prefix = "/"];
string config_path = 3 [(buf.validate.field).string.pattern = "^\\/.*|^$"];
// more detailed runtime objects
oneof details {
// NGINX runtime configuration settings like stub_status, usually read from the NGINX config or NGINX process
NGINXRuntimeInfo nginx_runtime_info = 4;
// NGINX Plus runtime configuration settings like api value, usually read from the NGINX config, NGINX process or NGINX Plus API
NGINXPlusRuntimeInfo nginx_plus_runtime_info = 5;
// NGINX App Protect runtime information
NGINXAppProtectRuntimeInfo nginx_app_protect_runtime_info = 7;
}
// List of worker processes
repeated InstanceChild instance_children = 6;
Expand Down Expand Up @@ -350,6 +354,16 @@ message APIDetails {
string listen = 2;
}

// A set of runtime NGINX App Protect settings
message NGINXAppProtectRuntimeInfo {
// NGINX App Protect Release
string release = 1;
// Attack signature version
string attack_signature_version = 2;
// Threat campaign version
string threat_campaign_version = 3;
}

// A set of actions that can be performed on an instance
message InstanceAction {}

Expand Down
20 changes: 20 additions & 0 deletions docs/proto/protos.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
- [InstanceRuntime](#mpi-v1-InstanceRuntime)
- [ManagementPlaneRequest](#mpi-v1-ManagementPlaneRequest)
- [MetricsServer](#mpi-v1-MetricsServer)
- [NGINXAppProtectRuntimeInfo](#mpi-v1-NGINXAppProtectRuntimeInfo)
- [NGINXPlusAction](#mpi-v1-NGINXPlusAction)
- [NGINXPlusRuntimeInfo](#mpi-v1-NGINXPlusRuntimeInfo)
- [NGINXRuntimeInfo](#mpi-v1-NGINXRuntimeInfo)
Expand Down Expand Up @@ -954,6 +955,7 @@ Meta-information relating to the reported instance
| config_path | [string](#string) | | the config path location |
| nginx_runtime_info | [NGINXRuntimeInfo](#mpi-v1-NGINXRuntimeInfo) | | NGINX runtime configuration settings like stub_status, usually read from the NGINX config or NGINX process |
| nginx_plus_runtime_info | [NGINXPlusRuntimeInfo](#mpi-v1-NGINXPlusRuntimeInfo) | | NGINX Plus runtime configuration settings like api value, usually read from the NGINX config, NGINX process or NGINX Plus API |
| nginx_app_protect_runtime_info | [NGINXAppProtectRuntimeInfo](#mpi-v1-NGINXAppProtectRuntimeInfo) | | NGINX App Protect runtime information |
| instance_children | [InstanceChild](#mpi-v1-InstanceChild) | repeated | List of worker processes |


Expand Down Expand Up @@ -992,6 +994,23 @@ The metrics settings associated with origins (sources) of the metrics and destin



<a name="mpi-v1-NGINXAppProtectRuntimeInfo"></a>

### NGINXAppProtectRuntimeInfo
A set of runtime NGINX App Protect settings


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| release | [string](#string) | | NGINX App Protect Release |
| attack_signature_version | [string](#string) | | Attack signature version |
| threat_campaign_version | [string](#string) | | Threat campaign version |






<a name="mpi-v1-NGINXPlusAction"></a>

### NGINXPlusAction
Expand Down Expand Up @@ -1209,6 +1228,7 @@ the types of instances possible
| INSTANCE_TYPE_NGINX | 2 | NGINX |
| INSTANCE_TYPE_NGINX_PLUS | 3 | NGINX Plus |
| INSTANCE_TYPE_UNIT | 4 | NGINX Unit |
| INSTANCE_TYPE_NGINX_APP_PROTECT | 5 | NGINX App Protect |



Expand Down
3 changes: 2 additions & 1 deletion internal/watcher/health/health_watcher_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func (hw *HealthWatcherService) AddHealthWatcher(instances []*mpi.Instance) {
hw.watchers[instance.GetInstanceMeta().GetInstanceId()] = watcher
case mpi.InstanceMeta_INSTANCE_TYPE_AGENT:
case mpi.InstanceMeta_INSTANCE_TYPE_UNSPECIFIED,
mpi.InstanceMeta_INSTANCE_TYPE_UNIT:
mpi.InstanceMeta_INSTANCE_TYPE_UNIT,
mpi.InstanceMeta_INSTANCE_TYPE_NGINX_APP_PROTECT:
fallthrough
default:
slog.Warn("Health watcher not implemented", "instance_type",
Expand Down
61 changes: 33 additions & 28 deletions internal/watcher/instance/instance_watcher_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import (
"sync"
"time"

"github.com/nginx/agent/v3/pkg/nginxprocess"

mpi "github.com/nginx/agent/v3/api/grpc/mpi/v1"
"github.com/nginx/agent/v3/internal/watcher/process"

"github.com/nginx/agent/v3/internal/config"
"github.com/nginx/agent/v3/internal/datasource/host/exec"
"github.com/nginx/agent/v3/internal/logger"
"github.com/nginx/agent/v3/internal/model"
"github.com/nginx/agent/v3/internal/watcher/process"
"github.com/nginx/agent/v3/pkg/nginxprocess"
)

const defaultAgentPath = "/run/nginx-agent"
Expand All @@ -40,16 +42,17 @@ type (
}

InstanceWatcherService struct {
processOperator process.ProcessOperatorInterface
nginxConfigParser nginxConfigParser
executer exec.ExecInterface
agentConfig *config.Config
instanceCache map[string]*mpi.Instance
nginxConfigCache map[string]*model.NginxConfigContext
instancesChannel chan<- InstanceUpdatesMessage
nginxConfigContextChannel chan<- NginxConfigContextMessage
processParsers []processParser
cacheMutex sync.Mutex
processOperator process.ProcessOperatorInterface
nginxConfigParser nginxConfigParser
executer exec.ExecInterface
agentConfig *config.Config
instanceCache map[string]*mpi.Instance
nginxConfigCache map[string]*model.NginxConfigContext
instancesChannel chan<- InstanceUpdatesMessage
nginxConfigContextChannel chan<- NginxConfigContextMessage
nginxParser processParser
nginxAppProtectProcessParser processParser
cacheMutex sync.Mutex
}

InstanceUpdates struct {
Expand All @@ -71,16 +74,15 @@ type (

func NewInstanceWatcherService(agentConfig *config.Config) *InstanceWatcherService {
return &InstanceWatcherService{
agentConfig: agentConfig,
processOperator: process.NewProcessOperator(),
processParsers: []processParser{
NewNginxProcessParser(),
},
nginxConfigParser: NewNginxConfigParser(agentConfig),
instanceCache: make(map[string]*mpi.Instance),
cacheMutex: sync.Mutex{},
nginxConfigCache: make(map[string]*model.NginxConfigContext),
executer: &exec.Exec{},
agentConfig: agentConfig,
processOperator: process.NewProcessOperator(),
nginxParser: NewNginxProcessParser(),
nginxAppProtectProcessParser: NewNginxAppProtectProcessParser(),
nginxConfigParser: NewNginxConfigParser(agentConfig),
instanceCache: make(map[string]*mpi.Instance),
cacheMutex: sync.Mutex{},
nginxConfigCache: make(map[string]*model.NginxConfigContext),
executer: &exec.Exec{},
}
}

Expand Down Expand Up @@ -245,7 +247,7 @@ func (iw *InstanceWatcherService) instanceUpdates(ctx context.Context) (
instanceUpdates InstanceUpdates,
err error,
) {
processes, err := iw.processOperator.Processes(ctx)
nginxProcesses, nginxAppProtectProcesses, err := iw.processOperator.Processes(ctx)
if err != nil {
return instanceUpdates, err
}
Expand All @@ -255,11 +257,14 @@ func (iw *InstanceWatcherService) instanceUpdates(ctx context.Context) (
agentInstance := iw.agentInstance(ctx)
instancesFound[agentInstance.GetInstanceMeta().GetInstanceId()] = agentInstance

for _, parser := range iw.processParsers {
instances := parser.Parse(ctx, processes)
for _, instance := range instances {
instancesFound[instance.GetInstanceMeta().GetInstanceId()] = instance
}
nginxInstances := iw.nginxParser.Parse(ctx, nginxProcesses)
for _, instance := range nginxInstances {
instancesFound[instance.GetInstanceMeta().GetInstanceId()] = instance
}

nginxAppProtectInstances := iw.nginxAppProtectProcessParser.Parse(ctx, nginxAppProtectProcesses)
for _, instance := range nginxAppProtectInstances {
instancesFound[instance.GetInstanceMeta().GetInstanceId()] = instance
}
newInstances, updatedInstances, deletedInstances := compareInstances(iw.instanceCache, instancesFound)

Expand Down
Loading