Giter Club home page Giter Club logo

logging-view-plugin's Introduction

Logging View Plugin for OpenShift Console

This plugin adds the logging view into the 'observe' menu in the OpenShift console. It requires OpenShift 4.10.

This plugin connects to a loki backend, you can install the loki-operator in your cluster.

Development

Node.js and npm are required to build and run the plugin. To run OpenShift console in a container, either Docker or podman 3.2.0+ and oc are required.

Running locally

Make sure you have loki running on http://localhost:3100

  1. Install the dependencies running make install
  2. Start the backend make start-backend
  3. In a different terminal start the frontend make start-frontend
  4. In a different terminal start the console a. oc login (requires oc and an OpenShift cluster) b. make start-console (requires Docker or podman 3.2.0+)

This will create an environment file web/scripts/env.list and run the OpenShift console in a container connected to the cluster you've logged into. The plugin backend server runs on port 9002 with CORS enabled.

The dynamic console plugin is configured to connect to loki using a proxy /api/proxy/plugin/logging-view-plugin/backend/, in local mode this will point to http://localhost:3100. You can disable this by re-running the console with npm run start:console -c to use the cluster proxy

Navigate to http://localhost:9000/monitoring/logs to see the running plugin.

Running tests

Unit tests

make test-unit

e2e tests

make test-frontend

this will build the frontend in standalone mode and run the cypress tests

Deployment on cluster

You can deploy the plugin to a cluster by instantiating the provided Plugin Resources. It will use the latest plugin docker image and run a light-weight go HTTP server to serve the plugin's assets.

oc create -f logging-view-plugin-resources.yml

Once deployed, patch the Console operator config to enable the plugin.

oc patch consoles.operator.openshift.io cluster \
  --patch '{ "spec": { "plugins": ["logging-view-plugin"] } }' --type=merge

Plugin configuration

The plugin can be configured by mounting a ConfigMap in the deployment and passing the -plugin-config-path flag with the file path, for example:

ConfigMap with plugin configuration

apiVersion: v1
kind: ConfigMap
metadata:
  name: logging-view-plugin-config
  namespace: openshift-logging
  labels:
    app: logging-view-plugin
    app.kubernetes.io/part-of: logging-view-plugin
data:
  config.yaml: |-
    logsLimit: 200
    timeout: '60s'

Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: logging-view-plugin
  namespace: openshift-logging
  labels:
    app: logging-view-plugin
    app.kubernetes.io/component: logging-view-plugin
    app.kubernetes.io/instance: logging-view-plugin
    app.kubernetes.io/part-of: logging-view-plugin
    app.openshift.io/runtime-namespace: openshift-logging
spec:
  replicas: 1
  selector:
    matchLabels:
      app: logging-view-plugin
  template:
    metadata:
      labels:
        app: logging-view-plugin
    spec:
      containers:
        - name: logging-view-plugin
          image: "quay.io/gbernal/logging-view-plugin:latest"
          args:
            - "-plugin-config-path"
            - "/etc/plugin/config.yaml"
            ...

          volumeMounts:
            - name: plugin-config
              readOnly: true
              mountPath: /etc/plugin/config.yaml
              subPath: config.yaml
            ...

      volumes:
        - name: plugin-conf
          configMap:
            name: logging-view-plugin-config
            defaultMode: 420
        ...

      ...

Configuration values

Field Description Default Unit
timeout fetch timeout when requesting logs 30s duration
logLimit maximum logs to be requested 100 units
alertingRuleTenantLabelKey name of the alerting rule label used to match the tenantId for log-based alerts. Allows log-based alerts to request metrics to the proper tenant endpoint tenantId string
alertingRuleNamespaceLabelKey name of the label used to filter alerting rules by namespace kubernetes_namespace_name string
useTenantInHeader whether or not the tenant header X-Scope-OrgID should be used instead of using the tenant in the URL request false boolean

Build a testint the image

make build-image

Features

From 5.6.1+, apart from the core functionality, the plugin offers additional features that can be enabled using the -features flag with comma separated values. For example:

-features=dev-console,alerts

In OpenShift console, these features will be enabled by the Cluster Logging Operator based on the cluster version.

Feature list

Feature Description
dev-console Adds the logging view to the developer perspective
alerts Merges the OpenShift console alerts with log-based alerts defined in the Loki ruler. Adds a log-based metrics chart in the alert detail view
dev-alerts Merges the OpenShift console alerts with log-based alerts defined in the Loki ruler. Adds a log-based metrics chart in the alert detail view for the developer perspective

Compatibility matrix

CLO version OCP versions Features
5.5 4.10 (tech preview), 4.11, 4.12 No features configuration, just core functionallity
5.6.1+ 4.10 (tech preview), 4.11 No additional features, just core functionallity
5.6.1+ 4.12, 4.13 dev-console
5.7 4.11 No additional features, just core functionallity
5.7 4.11.52+ dev-console
5.7 4.12 dev-console
5.7 4.13 dev-console, alerts
5.8 4.14 dev-console, alerts, dev-alerts

logging-view-plugin's People

Contributors

coverprice avatar jgbernalp avatar kyoto avatar openshift-ci[bot] avatar openshift-merge-bot[bot] avatar openshift-merge-robot avatar periklis avatar syedriko avatar xperimental avatar zhuje avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

logging-view-plugin's Issues

Logging-view container issues - Missing files

Hi there

On Dec I was able to deploy Loki in an OCP 4.10 (s390x arch) and enabling the logging-view console without problems
Logging operator was 5.4.3.
Something happened during the X-mas holidays (not sure if someone upgraded the operator manually or it was due automatically) but the. logging-view plugin is not longer running (now it is running 5.5)

I can see logs like the following

{"_ts":"2023-01-18T11:39:02.792504266Z","_level":"0","_component":"cluster-logging-operator","_message":"reconciling console","_error":{"msg":"ConsolePlugin.console.openshift.io \"logging-view-plugin\" is invalid: spec.proxy.service.name: Invalid value: \"\": spec.proxy.service.name in body should be at least 1 chars long"},"plugin":"console.openshift.io/v1alpha1/consoleplugins/logging-view-plugin"}

and

2023/01/18 12:09:04 [error] 7#0: *2 open() "/usr/share/nginx/html/locales/en/plugin_logging-view-plugin.json" failed (2: No such file or directory), client: 10.129.0.96, server: , request: "GET /locales/en/plugin_logging-view-plugin.json HTTP/1.1", host: "logging-view-plugin.openshift-logging.svc.cluster.local:9443", referrer: "https://console-openshift-console.apps.[redacted]/k8s/ns/openshift-logging/clusterserviceversions/cluster-logging.5.5.5/logging.openshift.io~v1~ClusterLogging/instance/yaml"

It seems there are some missing files in the container and OCP Console can't connect with the service and it is not shown in the console

I've tried to downgrade completely the stack (back to 5.4.9), and I can see the same thing

For some reason the plugin_logging-view-plugin.json is not in the docker image. Indeed there is no /usr/share/nginx/html/locales folder

Is anyone aware of that?

Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.