mirror of
https://github.com/netbirdio/docs.git
synced 2026-05-06 17:18:49 +00:00
564 lines
12 KiB
Plaintext
564 lines
12 KiB
Plaintext
export const title = 'Events'
|
|
|
|
|
|
|
|
## List all Audit Events {{ tag: 'GET' , label: '/api/events/audit' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Returns a list of all audit events
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="GET" label="/api/events/audit">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X GET https://api.netbird.io/api/events/audit \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'get',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/events/audit',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/events/audit"
|
|
|
|
headers = {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("GET", url, headers=headers)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/events/audit"
|
|
method := "GET"
|
|
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, nil)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/events/audit")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Get.new(url)
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/events/audit")
|
|
.method("GET")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/events/audit',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'GET',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
[
|
|
{
|
|
"id": 10,
|
|
"timestamp": "2023-05-05T10:04:37.473542Z",
|
|
"activity": "Route created",
|
|
"activity_code": "route.add",
|
|
"initiator_id": "google-oauth2|123456789012345678901",
|
|
"initiator_name": "John Doe",
|
|
"initiator_email": "demo@netbird.io",
|
|
"target_id": "chad9d86lnnc59g18ou0",
|
|
"meta": {
|
|
"name": "my route",
|
|
"network_range": "10.64.0.0/24",
|
|
"peer_id": "chacbco6lnnbn6cg5s91"
|
|
}
|
|
}
|
|
]
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
[
|
|
{
|
|
"id": "string",
|
|
"timestamp": "string",
|
|
"activity": "string",
|
|
"activity_code": "string",
|
|
"initiator_id": "string",
|
|
"initiator_name": "string",
|
|
"initiator_email": "string",
|
|
"target_id": "string",
|
|
"meta": {
|
|
"description": "The metadata of the event",
|
|
"type": "object",
|
|
"additionalProperties": "string",
|
|
"example": {
|
|
"name": "my route",
|
|
"network_range": "10.64.0.0/24",
|
|
"peer_id": "chacbco6lnnbn6cg5s91"
|
|
}
|
|
}
|
|
}
|
|
]
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|
|
|
|
|
|
## List all Traffic Events <Badge status="cloud-only" text="cloud-only" hoverText="This feature is only available in the cloud version of NetBird." /> <Badge status="experimental" text="experimental" hoverText="This feature is experimental. The endpoint will likely change and we do not guarantee backwards compatibility." /> {{ tag: 'GET' , label: '/api/events/network-traffic' }}
|
|
|
|
<Row>
|
|
<Col>
|
|
Returns a list of all network traffic events
|
|
|
|
### Query Parameters
|
|
<Properties>
|
|
|
|
<Property name="page" type="integer" required={false}>
|
|
Page number
|
|
</Property>
|
|
|
|
<Property name="page_size" type="integer" required={false}>
|
|
Number of items per page
|
|
</Property>
|
|
|
|
<Property name="user_id" type="string" required={false}>
|
|
Filter by user ID
|
|
</Property>
|
|
|
|
<Property name="reporter_id" type="string" required={false}>
|
|
Filter by reporter ID
|
|
</Property>
|
|
|
|
<Property name="protocol" type="integer" required={false}>
|
|
Filter by protocol
|
|
</Property>
|
|
|
|
<Property name="type" type="string" required={false}>
|
|
Filter by event type
|
|
</Property>
|
|
|
|
<Property name="connection_type" type="string" required={false}>
|
|
Filter by connection type
|
|
</Property>
|
|
|
|
<Property name="direction" type="string" required={false}>
|
|
Filter by direction
|
|
</Property>
|
|
|
|
<Property name="search" type="string" required={false}>
|
|
Case-insensitive partial match on user email, source/destination names, and source/destination addresses
|
|
</Property>
|
|
|
|
<Property name="start_date" type="string" required={false}>
|
|
Start date for filtering events (ISO 8601 format, e.g., 2024-01-01T00:00:00Z).
|
|
</Property>
|
|
|
|
<Property name="end_date" type="string" required={false}>
|
|
End date for filtering events (ISO 8601 format, e.g., 2024-01-31T23:59:59Z).
|
|
</Property>
|
|
</Properties>
|
|
</Col>
|
|
|
|
<Col sticky>
|
|
<CodeGroup title="Request" tag="GET" label="/api/events/network-traffic">
|
|
```bash {{ title: 'cURL' }}
|
|
curl -X GET https://api.netbird.io/api/events/network-traffic \
|
|
-H 'Accept: application/json' \
|
|
-H 'Authorization: Token <TOKEN>'
|
|
```
|
|
|
|
```js
|
|
const axios = require('axios');
|
|
|
|
let config = {
|
|
method: 'get',
|
|
maxBodyLength: Infinity,
|
|
url: '/api/events/network-traffic',
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
};
|
|
|
|
axios(config)
|
|
.then((response) => {
|
|
console.log(JSON.stringify(response.data));
|
|
})
|
|
.catch((error) => {
|
|
console.log(error);
|
|
});
|
|
```
|
|
|
|
```python
|
|
import requests
|
|
import json
|
|
|
|
url = "https://api.netbird.io/api/events/network-traffic"
|
|
|
|
headers = {
|
|
'Accept': 'application/json',
|
|
'Authorization': 'Token <TOKEN>'
|
|
}
|
|
|
|
response = requests.request("GET", url, headers=headers)
|
|
|
|
print(response.text)
|
|
```
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"net/http"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func main() {
|
|
|
|
url := "https://api.netbird.io/api/events/network-traffic"
|
|
method := "GET"
|
|
|
|
client := &http.Client {
|
|
}
|
|
req, err := http.NewRequest(method, url, nil)
|
|
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
{
|
|
|
|
req.Header.Add("Accept", "application/json")
|
|
req.Header.Add("Authorization", "Token <TOKEN>")
|
|
|
|
res, err := client.Do(req)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
body, err := ioutil.ReadAll(res.Body)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(string(body))
|
|
}
|
|
```
|
|
|
|
```ruby
|
|
require "uri"
|
|
require "json"
|
|
require "net/http"
|
|
|
|
url = URI("https://api.netbird.io/api/events/network-traffic")
|
|
|
|
https = Net::HTTP.new(url.host, url.port)
|
|
https.use_ssl = true
|
|
|
|
request = Net::HTTP::Get.new(url)
|
|
request["Accept"] = "application/json"
|
|
request["Authorization"] = "Token <TOKEN>"
|
|
|
|
response = https.request(request)
|
|
puts response.read_body
|
|
```
|
|
|
|
```java
|
|
OkHttpClient client = new OkHttpClient().newBuilder()
|
|
.build();
|
|
|
|
Request request = new Request.Builder()
|
|
.url("https://api.netbird.io/api/events/network-traffic")
|
|
.method("GET")
|
|
.addHeader("Accept", "application/json")
|
|
.addHeader("Authorization: Token <TOKEN>")
|
|
.build();
|
|
Response response = client.newCall(request).execute();
|
|
```
|
|
|
|
```php
|
|
<?php
|
|
|
|
$curl = curl_init();
|
|
|
|
curl_setopt_array($curl, array(
|
|
CURLOPT_URL => 'https://api.netbird.io/api/events/network-traffic',
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_ENCODING => '',
|
|
CURLOPT_MAXREDIRS => 10,
|
|
CURLOPT_TIMEOUT => 0,
|
|
CURLOPT_FOLLOWLOCATION => true,
|
|
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
|
CURLOPT_CUSTOMREQUEST => 'GET',
|
|
CURLOPT_HTTPHEADER => array(
|
|
'Accept: application/json',
|
|
'Authorization: Token <TOKEN>'
|
|
),
|
|
));
|
|
|
|
$response = curl_exec($curl);
|
|
|
|
curl_close($curl);
|
|
echo $response;
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
|
|
<CodeGroup title="Response">
|
|
```json {{ title: 'Example' }}
|
|
{
|
|
"data": [
|
|
{
|
|
"flow_id": "61092452-b17c-4b14-b7cf-a2158c549826",
|
|
"reporter_id": "ch8i4ug6lnn4g9hqv7m0",
|
|
"source": {
|
|
"id": "ch8i4ug6lnn4g9hqv7m0",
|
|
"type": "PEER",
|
|
"name": "My Peer",
|
|
"geo_location": {
|
|
"city_name": "Berlin",
|
|
"country_code": "DE"
|
|
},
|
|
"os": "Linux",
|
|
"address": "100.64.0.10:51820",
|
|
"dns_label": "*.mydomain.com"
|
|
},
|
|
"destination": {
|
|
"id": "ch8i4ug6lnn4g9hqv7m0",
|
|
"type": "PEER",
|
|
"name": "My Peer",
|
|
"geo_location": {
|
|
"city_name": "Berlin",
|
|
"country_code": "DE"
|
|
},
|
|
"os": "Linux",
|
|
"address": "100.64.0.10:51820",
|
|
"dns_label": "*.mydomain.com"
|
|
},
|
|
"user": {
|
|
"id": "google-oauth2|123456789012345678901",
|
|
"email": "alice@netbird.io",
|
|
"name": "Alice Smith"
|
|
},
|
|
"policy": {
|
|
"id": "ch8i4ug6lnn4g9hqv7m0",
|
|
"name": "All to All"
|
|
},
|
|
"icmp": {
|
|
"type": 8,
|
|
"code": 0
|
|
},
|
|
"protocol": 6,
|
|
"direction": "INGRESS",
|
|
"rx_bytes": 1234,
|
|
"rx_packets": 5,
|
|
"tx_bytes": 1234,
|
|
"tx_packets": 5,
|
|
"events": [
|
|
{
|
|
"type": "TYPE_START",
|
|
"timestamp": {}
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"page": {
|
|
"type": "integer",
|
|
"description": "Current page number"
|
|
},
|
|
"page_size": {
|
|
"type": "integer",
|
|
"description": "Number of items per page"
|
|
},
|
|
"total_records": {
|
|
"type": "integer",
|
|
"description": "Total number of event records available"
|
|
},
|
|
"total_pages": {
|
|
"type": "integer",
|
|
"description": "Total number of pages available"
|
|
}
|
|
}
|
|
```
|
|
```json {{ title: 'Schema' }}
|
|
{
|
|
"data": [
|
|
{
|
|
"flow_id": "string",
|
|
"reporter_id": "string",
|
|
"source": {
|
|
"id": "string",
|
|
"type": "string",
|
|
"name": "string",
|
|
"geo_location": {
|
|
"city_name": "string",
|
|
"country_code": "string"
|
|
},
|
|
"os": "string",
|
|
"address": "string",
|
|
"dns_label": "string"
|
|
},
|
|
"destination": {
|
|
"id": "string",
|
|
"type": "string",
|
|
"name": "string",
|
|
"geo_location": {
|
|
"city_name": "string",
|
|
"country_code": "string"
|
|
},
|
|
"os": "string",
|
|
"address": "string",
|
|
"dns_label": "string"
|
|
},
|
|
"user": {
|
|
"id": "string",
|
|
"email": "string",
|
|
"name": "string"
|
|
},
|
|
"policy": {
|
|
"id": "string",
|
|
"name": "string"
|
|
},
|
|
"icmp": {
|
|
"type": "integer",
|
|
"code": "integer"
|
|
},
|
|
"protocol": "integer",
|
|
"direction": "string",
|
|
"rx_bytes": "integer",
|
|
"rx_packets": "integer",
|
|
"tx_bytes": "integer",
|
|
"tx_packets": "integer",
|
|
"events": [
|
|
{
|
|
"type": "string",
|
|
"timestamp": "string"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"page": "integer",
|
|
"page_size": "integer",
|
|
"total_records": "integer",
|
|
"total_pages": "integer"
|
|
}
|
|
```
|
|
</CodeGroup>
|
|
|
|
|
|
</Col>
|
|
</Row>
|
|
|
|
---
|