Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 3 additions & 5 deletions .claude/commands/run-perses-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Then go clockwise and split horitzontally.
- Pane 2
- Path: monitoring-plugin (root of this repo)
- Label: monitoring-console-plugin-console
- Run: make start-feature-console
- Run: make start-console
- Pane 4
- Path: monitoring-plugin (root of this repo)
- Label: monitoring-console-plugin-backend
- Run: make start-feature-backend
- Run: make start-coo-backend
- Pane 6
- Path: monitoring-plugin (root of this repo)
- Label: port-forward-promtheus-operator
Expand All @@ -45,6 +45,4 @@ Then go clockwise and split horitzontally.
- In bold output, tell the user the name of the session and tmux session tips like how to attach to sessions, how to move around the panels using prefix + arrows, how to delete a session, how to list session
- Navigate to `{perses_path}/dev/config.yaml`. The spec `security.enable_auth` should be `false`.
- Tell user that openshift console platform is located at http://localhost:9000
- Tell user that perses is located at http://localhost:3000


- Tell user that perses is located at http://localhost:3000
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
- **What**: Dual frontend plugins for OpenShift observability (monitoring-plugin + monitoring-console-plugin)
- **Purpose**: Alerts, Metrics, Targets, Dashboards + Perses, Incidents, ACM integration
- **Tech Stack**: React + TypeScript + Webpack + i18next + Go
- **Key Files**: `web/console-extensions.json`, `web/src/components/`
- **Key Files**: `config/*.patch.json`, `web/src/components/`

## Common Tasks & Workflows

### Adding a New Feature

1. Check if it belongs in `monitoring-plugin` (core) or `monitoring-console-plugin` (extended)
2. Update console extensions in `web/console-extensions.json`
2. Add or update the relevant patch file in `config/` (e.g. `config/alerting.patch.json`)
3. Add React components in `web/src/components/`
4. Add translations in `public/locales/`
5. Test with `make lint-frontend && make test-backend`

### Debugging Issues

- **Build failures**: Check `Makefile` targets
- **Console integration**: Verify `console-extensions.json`
- **Console integration**: Verify the relevant `config/*.patch.json` patch file
- **Plugin loading**: Check OpenShift Console logs
- **Perses dashboards**: Debug at `web/src/components/dashboards/perses/`

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,11 @@ grep "^\.PHONY" Makefile | sed 's/.PHONY: //'

#### Port conflicts

If ports 9001 or 3000 are in use:
If ports 9443 or 3000 are in use:

```bash
# Find and kill processes
lsof -ti:9001 | xargs kill -9 # Backend
lsof -ti:9443 | xargs kill -9 # Backend
lsof -ti:3000 | xargs kill -9 # Frontend
```

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.mcp
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ COPY --from=web-builder /opt/app-root/web/dist /opt/app-root/web/dist
COPY --from=go-builder /opt/app-root/plugin-backend /opt/app-root
COPY --from=web-builder /opt/app-root/config /opt/app-root/config

ENTRYPOINT ["/opt/app-root/plugin-backend", "-static-path", "/opt/app-root/web/dist"]
ENTRYPOINT ["/opt/app-root/plugin-backend", "-static-path", "/opt/app-root/web/dist", "-config-path", "/opt/app-root/config"]
19 changes: 8 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ PLATFORMS ?= linux/arm64,linux/amd64
ORG ?= openshift-observability-ui
PLUGIN_NAME ?=monitoring-plugin
IMAGE ?= quay.io/${ORG}/${PLUGIN_NAME}:${VERSION}
FEATURES ?=incidents,perses-dashboards,dev-config
MONITORING_FEATURES ?=alerting,targets,legacy-dashboards,metrics
ALL_FEATURES ?=alerting,targets,legacy-dashboards,metrics,incidents,perses-dashboards

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ALL_FEATURES ?=alerting,targets,legacy-dashboards,metrics,incidents,perses-dashboards
ALL_FEATURES ?=$(MONITORING_FEATURES),incidents,perses-dashboards

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in latest commit


GOLANGCI_LINT = $(shell pwd)/_output/tools/bin/golangci-lint
GOLANGCI_LINT_VERSION ?= v2.11.3
Expand Down Expand Up @@ -52,7 +53,11 @@ build-backend:

.PHONY: start-backend
start-backend:
go run ./cmd/plugin-backend.go -port='9001' -config-path='./config' -static-path='./web/dist'
go run ./cmd/plugin-backend.go -port='9443' -config-path='./config' -static-path='./web/dist' -features='${MONITORING_FEATURES}'

.PHONY: start-coo-backend
start-coo-backend:
go run ./cmd/plugin-backend.go -port='9443' -config-path='./config' -static-path='./web/dist' -features='${ALL_FEATURES}'

.PHONY: test-backend
test-backend:
Expand Down Expand Up @@ -107,17 +112,9 @@ build-mcp-image:
build-dev-mcp-image:
DOCKER_FILE_NAME="Dockerfile.dev-mcp" REPO="monitoring-console-plugin" scripts/build-image.sh

.PHONY: start-feature-console
start-feature-console:
PLUGIN_PORT=9443 ./scripts/start-console.sh

.PHONY: start-feature-backend
start-feature-backend:
go run ./cmd/plugin-backend.go -port='9443' -config-path='./config' -static-path='./web/dist' -features='${FEATURES}'

.PHONY: start-devspace-backend
start-devspace-backend:
/opt/app-root/plugin-backend -port='9443' -cert='/var/cert/tls.crt' -key='/var/cert/tls.key' -static-path='/opt/app-root/web/dist' -config-path='/opt/app-root/config' -features='${FEATURES}'
/opt/app-root/plugin-backend -port='9443' -cert='/var/cert/tls.crt' -key='/var/cert/tls.key' -static-path='/opt/app-root/web/dist' -config-path='/opt/app-root/config' -features='${ALL_FEATURES}'

.PHONY: podman-cross-build
podman-cross-build:
Expand Down
51 changes: 26 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# OpenShift Monitoring Plugin

This plugin runs in one of two modes, with and without feature flags. When deployed without any feature flags enabled, it will add the monitoring UI to the OpenShift web console. This is most commonly seen in the [CMO](https://github.com/openshift/cluster-monitoring-operator) deployment of it, which is shipped by default with every OpenShift cluster. Documentation for this mode is located under the [monitoring-plugin](#monitoring-plugin) heading.
This plugin enables frontend UI based on feature flags passed to the backend. These features are generally grouped under two sets, those deployed by the [Cluster Monitoring Operator](https://github.com/openshift/cluster-monitoring-operator) (alerting, dashboards, metrics and targets) and those deployed by the [Cluster Observability Operator](https://github.com/rhobs/observability-operator) (ACM Alerting, Perses Dashboards, Incidents). CMO is included and enabled by default on most installations of OpenShift so observability signals needed for these features are expected to be present in any cluster, while the COO features utilize optional observability signals which are installed through COO. Information on running the plugin as it if were deployed through CMO can be found under the [monitoring-plugin](#monitoring-plugin) heading and the other set can be found under the [monitoring-console-plugin](#monitoring-console-plugin) heading.

## Feature Flags

Feature flags should be added to the Feature enum [here](pkg/server.go) and to the useFeature hook [here](web/src/components/hooks/useFeatures.ts). Whenever a feature is enabled, a set of related feature extension points is included in the plugin-manifest.json served by the backend. These feature extension points are created through the use of [json-patches](https://datatracker.ietf.org/doc/html/rfc6902), such as the `acm-alerting` patch [here](config/acm-alerting.patch.json). The server looks for a patch in the format of `{feature-flag-name}.patch.json` to apply. Some feature flags, such as `acm-alerting` require other flags to be set such as `alertmanager` and `thanos-querier` to instruct the backend how to communicate with the observability signals they utilize

| Feature | OCP Version |
|-------------------|-------------|
| acm-alerting | 4.14+ |
| perses-dashboards | 4.14+ |
| incidents | 4.17+ |
| alerting | 5.0+ |
| legacy-dashboards | 5.0+ |
| metrics | 5.0+ |
| targets | 5.0+ |

When started with feature flag(s), it will instead only add functionality to the OpenShift web console related to the features. Documentation for this mode is located under the [monitoring-console-plugin](#monitoring-console-plugin) heading.

## monitoring-plugin

Expand Down Expand Up @@ -30,7 +43,7 @@ Before you can deploy the plugin on a cluster, you must build an image and push
docker push quay.io/my-repository/my-plugin:latest
```

NOTE: If you have a Mac with Apple silicon, you will need to add the flag `--platform=linux/amd64` when building the image to target the correct platform to run in-cluster.
NOTE: If you have a Mac with Apple silicon, you will need to add the flag `--platform=linux/amd64` when building the image to target the correct platform to run in-cluster. We recommend utilizing the `make build-image` action to build and push the image.

### Deployment on cluster

Expand All @@ -50,25 +63,21 @@ Install the chart into a new namespace or an existing namespace as specified by
helm upgrade -i monitoring-plugin charts/openshift-console-plugin -n my-plugin-namespace --create-namespace --set plugin.image=my-plugin-image-location
```

### Redux Store

The monitoring-plugin is currently in a transitionary state as the remaining pages are moved from the [openshift/console](https://github.com/openshift/console) repo to this one. One such instance of this is the redux store [definition](https://github.com/openshift/console/blob/master/frontend/public/reducers/observe.ts), which lives within the `openshift/console` codebase.

Changes to the store must be completed in the `openshift/console` codebase and are not backwards compatible unless cherry-picked with purpose.

### Running using Devspace

Install the [devspace](https://www.devspace.sh/docs/getting-started/installation) cli.

1. Install the frontend dependencies running `make install-frontend`.
2. Start the frontend `make start-feature-frontend`.
2. Start the frontend `make start-frontend`.
4. Select the namespace the monitoring-plugin is located in `devspace use namespace openshift-monitoring`.
5. In a different terminal start the devspace sync `devspace dev`.

When running the `devspace dev` command, the pipeline will run the `scale_down_cmo` function to prevent CMO from fighting over control of the pod. After CMO has been scaled down, devspace will "take over" the monitoring-plugin pod, grabbing all of the certificates and backend binary and configuration to run in the devspace pod. The backend will stay the same as what is built in the Dockerfile.devspace file, only the frontend changes will be reflected live in cluster.

After the pod has been "taken over" Devspace begins a sync process which will mirror changes from you local `./web/dist` folder into the `/opt/app-root/web/dist` folder in the devspace pod. You can then make changes to your frontend files locally which will trigger the locally running webpack dev server to rebuild the `./web/dist` folder, which will trigger Devspace to re-synced. You can then reload your console webpage to see your local changes running in the cluster.

The devspace command will enable all features from a single deployment for easy development, however it does not install other needed observability signals, which will need to be created through COO.

After development you can run `devspace purge` which will cleanup and then call the `scale_up_cmo` pipeline.

### Local Development
Expand All @@ -93,9 +102,12 @@ $ podman machine start
# Install dependencies
$ make install

# Run the application
# Run the frontend
$ make start-frontend
# In a separate terminal
# Run the backend
$ make start-backend
# In a separate terminal
$ make start-console
```

Expand All @@ -121,17 +133,6 @@ Images for the mcp can be built by running the following command. Due to the lim
make build-dev-mcp-image
```

### Feature Flags

Feature flags are used by the mcp mode to dictate the specific features which are enabled when the server starts up. Feature flags should be added to the Feature enum [here](pkg/server.go) and to the useFeature hook [here](web/src/components/hooks/useFeatures.ts). When any feature flag is enabled the default extension points are overridden, including a new monitoring-console-plugin exclusive redux store and all extension points for the flags. These feature extension points are created through the use of [json-patches](https://datatracker.ietf.org/doc/html/rfc6902), such as the `acm-alerting` patch [here](config/acm-alerting.patch.json). The server looks for a patch in the format of `{feature-flag-name}.patch.json` to apply.

| Feature | OCP Version |
|-------------------|-------------|
| acm-alerting | 4.14+ |
| perses-dashboards | 4.14+ |
| incidents | 4.17+ |
| dev-config | |

#### ACM

Due to the extensive number of items which would need to be run to locally run the ACM perspective, the suggested development pattern is instead repeat installations with helm. A small number of scripts have been put together to help you deploy the monitoring-plugin in its `acm-alerting` configuration. REGISTRY_ORG and TAG variables are available to adjust the quay image generated and used for deployment. Certain build time changes to the codebase are created when running these scripts.
Expand Down Expand Up @@ -163,13 +164,13 @@ $ make install
$ make start-frontend

# In a separate terminal
$ make start-feature-console
$ make start-console

# In a separate terminal
$ make start-feature-backend
$ make start-coo-backend
```

`make start-feature-backend` will inject the `perses-dashboards`, `incidents`, and `dev-config` features by default. Features such as `acm-alerting` which take in extra parameters will need to run the `make start-feature-backend` command with the appropriate environment variables, such as `MONITORING_PLUGIN_ALERTMANAGER`.
`make start-coo-backend` will inject the `alerting,targets,legacy-dashboards,metrics,incidents,perses-dashboards` features.

#### Local Development with Perses Proxy
The bridge script `start-console.sh` is configured to proxy to a local Perses instance running at port `:8080`. To run the local Perses instance you will need to clone the [perses/perses](https://github.com/perses/perses) repository and follow the start up instructions in [ui/README.md](https://github.com/perses/perses/blob/63601751674403f626d1dea3dec168bdad0ef1c7/ui/README.md) :
Expand Down
2 changes: 1 addition & 1 deletion cmd/plugin-backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (
portArg = flag.Int("port", 9443, "server port to listen on\nports 9444 and 9445 reserved for other use")
certArg = flag.String("cert", "", "cert file path to enable TLS (disabled by default)")
keyArg = flag.String("key", "", "private key file path to enable TLS (disabled by default)")
featuresArg = flag.String("features", "", "enabled features, comma separated.\noptions: ['acm-alerting', 'incidents', 'dev-config', 'perses-dashboards']")
featuresArg = flag.String("features", "", "enabled features, comma separated.\noptions: ['acm-alerting', 'alerting', 'incidents', 'legacy-dashboards', 'metrics', 'targets', 'perses-dashboards', 'cluster-health-analyzer']")
staticPathArg = flag.String("static-path", "/opt/app-root/web/dist", "static files path to serve frontend")
configPathArg = flag.String("config-path", "/opt/app-root/config", "config files path")
pluginConfigArg = flag.String("plugin-config-path", "/etc/plugin/config.yaml", "plugin yaml configuration")
Expand Down
16 changes: 8 additions & 8 deletions config/acm-alerting.patch.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"op": "add",
"path": "/extensions/1",
"path": "/extensions/0",
"value": {
"type": "console.navigation/section",
"properties": {
Expand All @@ -14,7 +14,7 @@
},
{
"op": "add",
"path": "/extensions/1",
"path": "/extensions/0",
"value": {
"type": "console.page/route",
"properties": {
Expand All @@ -28,7 +28,7 @@
},
{
"op": "add",
"path": "/extensions/1",
"path": "/extensions/0",
"value": {
"type": "console.page/route",
"properties": {
Expand All @@ -40,7 +40,7 @@
},
{
"op": "add",
"path": "/extensions/1",
"path": "/extensions/0",
"value": {
"type": "console.page/route",
"properties": {
Expand All @@ -52,7 +52,7 @@
},
{
"op": "add",
"path": "/extensions/1",
"path": "/extensions/0",
"value": {
"type": "console.page/route",
"properties": {
Expand All @@ -66,7 +66,7 @@
},
{
"op": "add",
"path": "/extensions/1",
"path": "/extensions/0",
"value": {
"type": "console.page/route",
"properties": {
Expand All @@ -80,7 +80,7 @@
},
{
"op": "add",
"path": "/extensions/1",
"path": "/extensions/0",
"value": {
"type": "console.page/route",
"properties": {
Expand All @@ -92,7 +92,7 @@
},
{
"op": "add",
"path": "/extensions/1",
"path": "/extensions/0",
"value": {
"type": "console.navigation/href",
"properties": {
Expand Down
Loading