Before building from source, be sure to install:
On macOS systems with Homebrew, run: brew install go@1.24 protobuf
-
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.
-
Clone this repository:
git clone https://github.com/mondoohq/cnspec.git cd cnspec -
Build and install:
To install cnspec using Go into the $GOBIN directory:
make cnspec/install
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 prepYou also need to have the required dependencies present:
make prep/reposWhen the repo is already present and something changed upstream, update the dependencies:
make prep/repos/updateThen, whenever you make changes, just run:
make cnspec/generateThis generates and updates all required files for the build. At this point you can make cnspec/install again as outlined above.
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.
cnspecinDEBUGmode: Exposes basic metrics
- Install
prometheusfrom https://prometheus.io/download/ (macOS:brew install prometheus) - Start both, Prometheus and Grafana with
make metrics/start - (one time only) Create a Grafana Dashboard
- Open Grafana at http://localhost:3000
- Add Prometheus as a data source (URL:
http://host.docker.internal:9009) - Use an existing Go profiling dashboard from Grafana dashboards e.g. 10826
- Run
cnspecwithDEBUG=1e.g.DEBUG=1 cnspec scan local
You should start seeing data in Grafana!
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
