Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/newrelic4
Browse files Browse the repository at this point in the history
  • Loading branch information
shahargl authored Sep 8, 2024
2 parents aa1ad4e + 4f109b6 commit 2d88f1e
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/providers/documentation/victoriametrics-provider.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ The Victoriametrics provider requires the following authentication parameters:
1. Ensure you have a running instance of VMAlert accessible by the host and port specified.
2. Include the host and port information in your Victoriametrics provider configuration when initializing the provider.

## Querying Victoriametrics

The Victoriametrics provider allows you to query from Victoriametrics through `query` and `query_range` types. The following are the parameters available for querying:

1. `query` type:
- `query`: The query to execute on Victoriametrics. Example: `sum(rate(http_requests_total{job="api-server"}[5m]))`.
- `start`: The time to query the data for. Example: `2024-01-01T00:00:00Z`

2. `query_range` type:
- `query`: The query to execute on Victoriametrics. Example: `sum(rate(http_requests_total{job="api-server"}[5m]))`.
- `start`: The start time to query the data for. Example: `2024-01-01T00:00:00Z`
- `end`: The end time to query the data for. Example: `2024-01-01T00:00:00Z`
- `step`: The step size to use for the query. Example: `15s`

## Push alerts to keep using webhooks

Expand Down
15 changes: 15 additions & 0 deletions examples/workflows/query_victoriametrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
workflow:
id: query-victoriametrics
name: victoriametrics
description: victoriametrics
triggers:
- type: manual
steps:
- name: victoriametrics-step
provider:
config: "{{ providers.victoriametrics }}"
type: victoriametrics
with:
query: process_memory_limit_bytes
queryType: query
actions: []
33 changes: 33 additions & 0 deletions keep/providers/victoriametrics_provider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Guide to deploy VictoriaMetrics using docker

### 1. Clone the repository

```bash
git clone https://github.com/VictoriaMetrics/VictoriaMetrics.git
```

### 2. Change the directory to docker

```bash
cd deployment/docker
```

### 3. Change the ports in the docker-compose file to avoid conflicts with the keep services

```bash
sed -i -e 's/3000:3000/3001:3000/' -e 's/127.0.0.1:3000/127.0.0.1:3001/' docker-compose.yml
```

### 3. Run the docker-compose file

```bash
docker-compose up -d
```

### 4. You can access the following services on the following ports

vicotriametrics - [http://localhost:8428](http://localhost:8428)
grafana - [http://localhost:3001](http://localhost:3001)
vmagent - [http://localhost:8429](http://localhost:8429)
vmalert - [http://localhost:8880](http://localhost:8880)
alertmanager - [http://localhost:9093](http://localhost:9093)
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,30 @@ def _get_alerts(self) -> list[AlertDto]:
else:
self.logger.error("Failed to get alerts", extra=response.json())
raise Exception("Could not get alerts")

def _query(self, query="", start="", end="", step="", queryType="", **kwargs:dict):
if queryType == "query":
response = requests.get(
f"{self.vmalert_host}:{self.authentication_config.VMAlertPort}/api/v1/query",
params={"query": query, "time": start},
)
if response.status_code == 200:
return response.json()
else:
self.logger.error("Failed to perform instant query", extra=response.json())
raise Exception("Could not perform instant query")

elif queryType == "query_range":
response = requests.get(
f"{self.vmalert_host}:{self.authentication_config.VMAlertPort}/api/v1/query_range",
params={"query": query, "start": start, "end": end, "step": step},
)
if response.status_code == 200:
return response.json()
else:
self.logger.error("Failed to perform range query", extra=response.json())
raise Exception("Could not range query")

else:
self.logger.error("Invalid query type")
raise Exception("Invalid query type")

0 comments on commit 2d88f1e

Please sign in to comment.