Skip to content

Commit f0fd305

Browse files
committed
Merge branch 'v3' into add-cert-rotation
2 parents a577471 + e79d42d commit f0fd305

File tree

16 files changed

+948
-271
lines changed

16 files changed

+948
-271
lines changed

api/grpc/mpi/v1/command.pb.go

Lines changed: 306 additions & 198 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/grpc/mpi/v1/command.pb.validate.go

Lines changed: 149 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/grpc/mpi/v1/command.proto

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ message InstanceMeta {
273273
INSTANCE_TYPE_NGINX_PLUS = 3;
274274
// NGINX Unit
275275
INSTANCE_TYPE_UNIT = 4;
276+
// NGINX App Protect
277+
INSTANCE_TYPE_NGINX_APP_PROTECT = 5;
276278
}
277279
// the types of instances possible
278280
InstanceType instance_type = 2;
@@ -296,13 +298,15 @@ message InstanceRuntime {
296298
// the binary path location
297299
string binary_path = 2 [(buf.validate.field).string.prefix = "/"];
298300
// the config path location
299-
string config_path = 3 [(buf.validate.field).string.prefix = "/"];
301+
string config_path = 3 [(buf.validate.field).string.pattern = "^\\/.*|^$"];
300302
// more detailed runtime objects
301303
oneof details {
302304
// NGINX runtime configuration settings like stub_status, usually read from the NGINX config or NGINX process
303305
NGINXRuntimeInfo nginx_runtime_info = 4;
304306
// NGINX Plus runtime configuration settings like api value, usually read from the NGINX config, NGINX process or NGINX Plus API
305307
NGINXPlusRuntimeInfo nginx_plus_runtime_info = 5;
308+
// NGINX App Protect runtime information
309+
NGINXAppProtectRuntimeInfo nginx_app_protect_runtime_info = 7;
306310
}
307311
// List of worker processes
308312
repeated InstanceChild instance_children = 6;
@@ -350,6 +354,16 @@ message APIDetails {
350354
string listen = 2;
351355
}
352356

357+
// A set of runtime NGINX App Protect settings
358+
message NGINXAppProtectRuntimeInfo {
359+
// NGINX App Protect Release
360+
string release = 1;
361+
// Attack signature version
362+
string attack_signature_version = 2;
363+
// Threat campaign version
364+
string threat_campaign_version = 3;
365+
}
366+
353367
// A set of actions that can be performed on an instance
354368
message InstanceAction {}
355369

docs/proto/protos.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
- [InstanceRuntime](#mpi-v1-InstanceRuntime)
6666
- [ManagementPlaneRequest](#mpi-v1-ManagementPlaneRequest)
6767
- [MetricsServer](#mpi-v1-MetricsServer)
68+
- [NGINXAppProtectRuntimeInfo](#mpi-v1-NGINXAppProtectRuntimeInfo)
6869
- [NGINXPlusAction](#mpi-v1-NGINXPlusAction)
6970
- [NGINXPlusRuntimeInfo](#mpi-v1-NGINXPlusRuntimeInfo)
7071
- [NGINXRuntimeInfo](#mpi-v1-NGINXRuntimeInfo)
@@ -954,6 +955,7 @@ Meta-information relating to the reported instance
954955
| config_path | [string](#string) | | the config path location |
955956
| nginx_runtime_info | [NGINXRuntimeInfo](#mpi-v1-NGINXRuntimeInfo) | | NGINX runtime configuration settings like stub_status, usually read from the NGINX config or NGINX process |
956957
| 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 |
958+
| nginx_app_protect_runtime_info | [NGINXAppProtectRuntimeInfo](#mpi-v1-NGINXAppProtectRuntimeInfo) | | NGINX App Protect runtime information |
957959
| instance_children | [InstanceChild](#mpi-v1-InstanceChild) | repeated | List of worker processes |
958960

959961

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

993995

994996

997+
<a name="mpi-v1-NGINXAppProtectRuntimeInfo"></a>
998+
999+
### NGINXAppProtectRuntimeInfo
1000+
A set of runtime NGINX App Protect settings
1001+
1002+
1003+
| Field | Type | Label | Description |
1004+
| ----- | ---- | ----- | ----------- |
1005+
| release | [string](#string) | | NGINX App Protect Release |
1006+
| attack_signature_version | [string](#string) | | Attack signature version |
1007+
| threat_campaign_version | [string](#string) | | Threat campaign version |
1008+
1009+
1010+
1011+
1012+
1013+
9951014
<a name="mpi-v1-NGINXPlusAction"></a>
9961015

9971016
### NGINXPlusAction
@@ -1209,6 +1228,7 @@ the types of instances possible
12091228
| INSTANCE_TYPE_NGINX | 2 | NGINX |
12101229
| INSTANCE_TYPE_NGINX_PLUS | 3 | NGINX Plus |
12111230
| INSTANCE_TYPE_UNIT | 4 | NGINX Unit |
1231+
| INSTANCE_TYPE_NGINX_APP_PROTECT | 5 | NGINX App Protect |
12121232

12131233

12141234

internal/collector/otel_collector_plugin.go

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"sync"
1515
"time"
1616

17+
pkgConfig "github.com/nginx/agent/v3/pkg/config"
18+
1719
"github.com/nginx/agent/v3/api/grpc/mpi/v1"
1820
"github.com/nginx/agent/v3/internal/backoff"
1921
"github.com/nginx/agent/v3/internal/bus"
@@ -408,28 +410,36 @@ func (oc *Collector) checkForNewReceivers(nginxConfigContext *model.NginxConfigC
408410

409411
reloadCollector = true
410412
} else if nginxConfigContext.PlusAPI.URL == "" {
411-
nginxReceiverFound, reloadCollector = oc.updateExistingNginxOSSReceiver(nginxConfigContext)
412-
413-
if !nginxReceiverFound && nginxConfigContext.StubStatus.URL != "" {
414-
oc.config.Collector.Receivers.NginxReceivers = append(
415-
oc.config.Collector.Receivers.NginxReceivers,
416-
config.NginxReceiver{
417-
InstanceID: nginxConfigContext.InstanceID,
418-
StubStatus: config.APIDetails{
419-
URL: nginxConfigContext.StubStatus.URL,
420-
Listen: nginxConfigContext.StubStatus.Listen,
421-
Location: nginxConfigContext.StubStatus.Location,
422-
},
423-
AccessLogs: toConfigAccessLog(nginxConfigContext.AccessLogs),
424-
},
425-
)
413+
reloadCollector = oc.addNginxOssReceiver(nginxConfigContext)
414+
}
426415

416+
if oc.config.IsFeatureEnabled(pkgConfig.FeatureLogsNap) {
417+
tcplogReceiversFound := oc.updateTcplogReceivers(nginxConfigContext)
418+
if tcplogReceiversFound {
427419
reloadCollector = true
428420
}
429421
}
430422

431-
tcplogReceiversFound := oc.updateTcplogReceivers(nginxConfigContext)
432-
if tcplogReceiversFound {
423+
return reloadCollector
424+
}
425+
426+
func (oc *Collector) addNginxOssReceiver(nginxConfigContext *model.NginxConfigContext) bool {
427+
nginxReceiverFound, reloadCollector := oc.updateExistingNginxOSSReceiver(nginxConfigContext)
428+
429+
if !nginxReceiverFound && nginxConfigContext.StubStatus.URL != "" {
430+
oc.config.Collector.Receivers.NginxReceivers = append(
431+
oc.config.Collector.Receivers.NginxReceivers,
432+
config.NginxReceiver{
433+
InstanceID: nginxConfigContext.InstanceID,
434+
StubStatus: config.APIDetails{
435+
URL: nginxConfigContext.StubStatus.URL,
436+
Listen: nginxConfigContext.StubStatus.Listen,
437+
Location: nginxConfigContext.StubStatus.Location,
438+
},
439+
AccessLogs: toConfigAccessLog(nginxConfigContext.AccessLogs),
440+
},
441+
)
442+
433443
reloadCollector = true
434444
}
435445

internal/watcher/health/health_watcher_service.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ func (hw *HealthWatcherService) AddHealthWatcher(instances []*mpi.Instance) {
6161
hw.watchers[instance.GetInstanceMeta().GetInstanceId()] = watcher
6262
case mpi.InstanceMeta_INSTANCE_TYPE_AGENT:
6363
case mpi.InstanceMeta_INSTANCE_TYPE_UNSPECIFIED,
64-
mpi.InstanceMeta_INSTANCE_TYPE_UNIT:
64+
mpi.InstanceMeta_INSTANCE_TYPE_UNIT,
65+
mpi.InstanceMeta_INSTANCE_TYPE_NGINX_APP_PROTECT:
6566
fallthrough
6667
default:
6768
slog.Warn("Health watcher not implemented", "instance_type",

0 commit comments

Comments
 (0)