Skip to content

Commit

Permalink
[DOCS] adding analyze service monitor docs
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Takashi <nicolas.tcs@hotmail.com>
  • Loading branch information
nicolastakashi committed Sep 4, 2024
1 parent 06283f2 commit 41f44cc
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions Documentation/commands/analyze/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Analyze Command

The analyze command is used to examine Prometheus Operator objects to ensure they comply with specific rules. It checks whether the objects meet certain predefined conditions.

```bash mdox-exec="go run main.go analyze --help" mdox-expect-exit-code=0
Analyzes the given object and runs a set of rules on it to determine if it is compliant with the given rules.
For example:
- Analyze if the service monitor is selecting any service or using the correct service port.

Usage:
poctl analyze [flags]

Flags:
-h, --help help for analyze
-k, --kind string The kind of object to analyze. For example, ServiceMonitor
-n, --name string The name of the object to analyze
-s, --namespace string The namespace of the object to analyze

Global Flags:
--kubeconfig string path to the kubeconfig file, defaults to $KUBECONFIG
--log-format string Log format (default "text")
--log-level string Log level (default "DEBUG")
```

## Analyze ServiceMonitor

The analyze command can specifically target a ServiceMonitor object within a Kubernetes cluster. Users can specify the namespace and name of the ServiceMonitor to assess its compliance with the predefined rules.

```bash mdox-exec="go run main.go analyze servicemonitor --help" mdox-expect-exit-code=0
Analyzes the given object and runs a set of rules on it to determine if it is compliant with the given rules.
For example:
- Analyze if the service monitor is selecting any service or using the correct service port.

Usage:
poctl analyze [flags]

Flags:
-h, --help help for analyze
-k, --kind string The kind of object to analyze. For example, ServiceMonitor
-n, --name string The name of the object to analyze
-s, --namespace string The namespace of the object to analyze

Global Flags:
--kubeconfig string path to the kubeconfig file, defaults to $KUBECONFIG
--log-format string Log format (default "text")
--log-level string Log level (default "DEBUG")
```

## Rules

The analyze command evaluates objects against a set of rules to determine compliance. These rules are defined in the `analyzer` package and are specifically implemented in the `internal/analyzer/servicemonitor.go` file.


### ServiceMonitor Existence

The ServiceMonitor object must exist in the Kubernetes cluster.

### Selector Presence

The ServiceMonitor object must have a defined selector that selects at least one service.

### Port Matching

Each endpoint within the ServiceMonitor object must have a defined port, and this port should match the port of the service it monitors.

0 comments on commit 41f44cc

Please sign in to comment.