Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GO_CODEGEN_INIT := $(BUILD_DIR)/rest_server/dist/.init_done
export TOPDIR MGMT_COMMON_DIR GO GOPATH

.PHONY: all
all: rest cli
all: rest cli observabilityd

$(GO_MOD):
$(GO) mod init github.com/Azure/sonic-mgmt-framework
Expand Down Expand Up @@ -59,6 +59,10 @@ clish:
rest: $(GO_DEPS) models
$(MAKE) -C rest

.PHONY: observabilityd
observabilityd:
$(MAKE) -C observabilityd

# Special target for local compilation of REST server binary.
# Compiles models, translib and cvl schema from sonic-mgmt-common
rest-server: go-deps-clean
Expand All @@ -78,10 +82,13 @@ models: | $(GO_CODEGEN_INIT)
models-clean:
$(MAKE) -C models clean

clean: rest-clean models-clean
clean: rest-clean models-clean observabilityd-clean
git check-ignore debian/* | xargs -r $(RM) -r
$(RM) -r debian/.debhelper
$(RM) -r $(BUILD_DIR)

observabilityd-clean:
$(MAKE) -C observabilityd clean

cleanall: clean

1 change: 1 addition & 0 deletions debian/sonic-mgmt-framework.install
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build/rest_server/rest_server usr/sbin
build/rest_server/generate_cert usr/sbin
build/rest_server/dist/ui etc/rest_server
build/cli usr/sbin
build/observabilityd/observabilityd usr/sbin
45 changes: 45 additions & 0 deletions observabilityd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
################################################################################
# #
# Copyright 2019 Broadcom. The term Broadcom refers to Broadcom Inc. and/or #
# its subsidiaries. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY #
# KIND, either express or implied. See the License for the specific language #
# governing permissions and limitations under the License. #
# #
################################################################################

TOPDIR := ..
BUILD_DIR ?= $(TOPDIR)/build

GO ?= go
GOROOT ?= $(shell $(GO) env GOROOT)

OBSERVABILITYD_BUILD_DIR := $(BUILD_DIR)/observabilityd
OBSERVABILITYD_BIN := $(OBSERVABILITYD_BUILD_DIR)/observabilityd

OBSERVABILITYD_GO_SRCS = $(shell find . -name '*.go' -not -name '*_test.go')

all: $(OBSERVABILITYD_BIN)

$(OBSERVABILITYD_BUILD_DIR)/:
mkdir -p $@

# Observabilityd binary
$(OBSERVABILITYD_BIN): $(OBSERVABILITYD_GO_SRCS) | $(OBSERVABILITYD_BUILD_DIR)/
@echo 'Building observabilityd...'
$(GO) mod tidy
$(GO) build -buildvcs=false -o $@ .
@echo 'Finished building observabilityd'

clean:
$(RM) $(OBSERVABILITYD_BIN)

.PHONY: all clean
42 changes: 42 additions & 0 deletions observabilityd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# observabilityd (sonic-mgmt-framework)

Small daemon that consumes CONFIG_DB updates for:

- `OBSERVABILITY_CONNECTOR|splunk` (`url`, `token`)
- `OBSERVABILITY_CONNECTOR|datadog` (`url`, `api_key`, `app_key`)

and posts a JSON event to the configured backend whenever the connector config changes.

## How it watches ConfigDB

- **Primary**: Redis keyspace notifications (pattern subscribe on `__keyspace@4__:OBSERVABILITY_CONNECTOR|*`)
- **Fallback**: periodic polling (default `--poll=5s`)

Keyspace notifications require Redis `notify-keyspace-events` to include keyspace/hash events (e.g. `KEA` or at least `Kh`).

## Build

```bash
cd sonic-mgmt-framework/observabilityd
go mod tidy
go build -o observabilityd .
```

## Run

```bash
./observabilityd --redis-sock /var/run/redis/redis.sock --db 4 --poll 5s
```

If you want TCP redis:

```bash
./observabilityd --redis-addr 127.0.0.1:6379 --db 4
```

## Notes

- `splunk url` is expected to be a full HTTP endpoint (e.g. Splunk HEC).
- `datadog url` is treated as a generic HTTP JSON endpoint; the daemon sends `DD-API-KEY` and `DD-APPLICATION-KEY` headers.


10 changes: 10 additions & 0 deletions observabilityd/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/sonic-net/sonic-mgmt-framework/observabilityd

go 1.19

require github.com/redis/go-redis/v9 v9.6.1

require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
)
8 changes: 8 additions & 0 deletions observabilityd/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4=
github.com/redis/go-redis/v9 v9.6.1/go.mod h1:0C0c6ycQsdpVNQpxb1njEQIqkx5UcsM8FJCQLgE9+RA=
Loading
Loading