Skip to content

Latest commit

 

History

History
101 lines (64 loc) · 2.97 KB

File metadata and controls

101 lines (64 loc) · 2.97 KB

Development

Build

Prerequisites

Before building from source, be sure to install:

On macOS systems with Homebrew, run: brew install go@1.24 protobuf

Install from source

  1. Verify that you have Go 1.24+ installed:

    go version

If go is not installed or an older version exists, follow instructions on the Go website.

  1. Clone this repository:

    git clone https://github.com/mondoohq/cnspec.git
    cd cnspec
  2. Build and install:

    Unix-like systems

    To install cnspec using Go into the $GOBIN directory:

    make cnspec/install

Develop cnspec

Whenever you change protos or other auto-generated files, you must regenerate files for the compiler. To do this, be sure you have the necessary tools installed (such as protobuf):

make prep

You also need to have the required dependencies present:

make prep/repos

When the repo is already present and something changed upstream, update the dependencies:

make prep/repos/update

Then, whenever you make changes, just run:

make cnspec/generate

This generates and updates all required files for the build. At this point you can make cnspec/install again as outlined above.

Metrics (Prometheus + Grafana)

When debugging cnspec, you can monitor and profile memory and CPU usage using Prometheus and Grafana. The setup provides visibility into application performance metrics and allows us to diagnose bottlenecks, memory leaks, and high CPU usage.

How it works?

  • Prometheus: Scrapes and stores time series metrics from your application.
  • Grafana: Visualizes the metrics and allows creating dashboards and alerts.
  • cnspec in DEBUG mode: Exposes basic metrics

Setup

  1. Install prometheus from https://prometheus.io/download/ (macOS: brew install prometheus)
  2. Start both, Prometheus and Grafana with make metrics/start
  3. (one time only) Create a Grafana Dashboard
    1. Open Grafana at http://localhost:3000
    2. Add Prometheus as a data source (URL: http://host.docker.internal:9009)
    3. Use an existing Go profiling dashboard from Grafana dashboards e.g. 10826
  4. Run cnspec with DEBUG=1 e.g. DEBUG=1 cnspec scan local

You should start seeing data in Grafana!

Grafana_dashboard

Contribute changes

Mark PRs with emojis

We love emojis in our commits. These are their meanings:

🛑 breaking 🐛 bugfix 🧹 cleanup/internals ⚡ speed 📄 docs ✨⭐🌟🌠 smaller or larger features 🐎 race condition 🌙 MQL 🌈 visual 🟢 fix tests 🎫 auth 🦅 falcon 🐳 container