-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from devopshobbies/grafana/datasources
feat(grafana): Creation of Grafana data sources based on user inputs
- Loading branch information
Showing
36 changed files
with
889 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: 1 | ||
datasources: | ||
- name: Mimir | ||
uid: mimir | ||
type: prometheus | ||
access: proxy | ||
orgId: 1 | ||
url: http://mimir-nginx.mimir.svc.cluster.local/prometheus | ||
editable: true | ||
version: 1 | ||
jsonData: | ||
alertmanagerUid: alertmanager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: 1 | ||
|
||
datasources: | ||
- name: Alertmanager | ||
uid: alertmanager | ||
type: alertmanager | ||
url: http://localhost:9093 | ||
access: proxy | ||
orgId: 1 | ||
jsonData: | ||
# Valid options for implementation include mimir, cortex and prometheus | ||
implementation: [prometheus|cortex|mimir] | ||
# Whether or not Grafana should send alert instances to this Alertmanager | ||
handleGrafanaManagedAlerts: [false|true] | ||
|
||
editable: [true|false] | ||
# optionally | ||
basicAuth: true | ||
basicAuthUser: my_user | ||
secureJsonData: | ||
basicAuthPassword: test_password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: 1 | ||
|
||
datasources: | ||
- name: elasticsearch-v7-filebeat | ||
type: elasticsearch | ||
access: proxy | ||
url: http://localhost:9200 | ||
editable: [true|false] | ||
jsonData: | ||
index: '[filebeat-]YYYY.MM.DD' | ||
interval: Daily | ||
timeField: '@timestamp' | ||
logMessageField: message | ||
logLevelField: fields.level |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: 1 | ||
|
||
datasources: | ||
- name: Loki | ||
uid: loki | ||
type: loki | ||
orgId: 1 | ||
access: proxy | ||
editable: [true|false] | ||
url: http://localhost:3100 | ||
jsonData: | ||
timeout: 60 | ||
maxLines: 1000 | ||
|
||
# optionally | ||
basicAuth: true | ||
basicAuthUser: my_user | ||
secureJsonData: | ||
basicAuthPassword: test_password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: 1 | ||
|
||
datasources: | ||
- name: Mimir | ||
uid: mimir | ||
type: prometheus | ||
access: proxy | ||
orgId: 1 | ||
url: http://mimir-nginx.mimir.svc.cluster.local/prometheus | ||
editable: [true|false] | ||
version: 1 | ||
jsonData: | ||
httpHeaderName1: "X-Scope-OrgID" | ||
alertmanagerUid: "alertmanager" | ||
secureJsonData: | ||
httpHeaderValue1: "pods" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: 1 | ||
|
||
datasources: | ||
- name: MySQL | ||
type: mysql | ||
url: localhost:3306 | ||
user: grafana | ||
editable: [true|false] | ||
jsonData: | ||
tlsAuth: true | ||
tlsSkipVerify: true | ||
database: grafana | ||
maxOpenConns: 100 # Grafana v5.4+ | ||
maxIdleConns: 100 # Grafana v5.4+ | ||
maxIdleConnsAuto: true # Grafana v9.5.1+ | ||
connMaxLifetime: 14400 # Grafana v5.4+ | ||
secureJsonData: | ||
password: ${GRAFANA_MYSQL_PASSWORD} | ||
tlsClientCert: ${GRAFANA_TLS_CLIENT_CERT} | ||
tlsCACert: ${GRAFANA_TLS_CA_CERT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: 1 | ||
|
||
datasources: | ||
- name: Postgres | ||
type: postgres | ||
url: localhost:5432 | ||
user: grafana # Database user’s login/username | ||
editable: [true|false] | ||
secureJsonData: | ||
password: 'Password!' | ||
jsonData: | ||
database: grafana | ||
sslmode: 'disable' # disable/require/verify-ca/verify-full | ||
maxOpenConns: 100 # Grafana v5.4+ | ||
maxIdleConns: 100 # Grafana v5.4+ | ||
maxIdleConnsAuto: true # Grafana v9.5.1+ | ||
connMaxLifetime: 14400 # Grafana v5.4+ | ||
postgresVersion: 903 # 903=9.3, 904=9.4, 905=9.5, 906=9.6, 1000=10 | ||
timescaledb: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: 1 | ||
|
||
datasources: | ||
- name: Prometheus | ||
uid: prometheus | ||
type: prometheus | ||
access: proxy | ||
# Access mode - proxy (server in the UI) or direct (browser in the UI). | ||
url: http://localhost:9090 | ||
editable: [true|false] | ||
jsonData: | ||
httpMethod: POST | ||
manageAlerts: true | ||
prometheusType: Prometheus | ||
prometheusVersion: 2.44.0 | ||
cacheLevel: 'High' | ||
disableRecordingRules: false | ||
incrementalQueryOverlapWindow: 10m | ||
exemplarTraceIdDestinations: | ||
# Field with internal link pointing to data source in Grafana. | ||
# datasourceUid value can be anything, but it should be unique across all defined data source uids. | ||
- datasourceUid: my_jaeger_uid | ||
name: traceID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: 1 | ||
|
||
datasources: | ||
- name: Tempo | ||
type: tempo | ||
access: proxy | ||
orgId: 1 | ||
url: http://tempo-query-frontend.tempo.svc.cluster.local:3100 | ||
basicAuth: false | ||
version: 1 | ||
editable: true | ||
apiVersion: 1 | ||
uid: tempo | ||
jsonData: | ||
httpMethod: GET | ||
tracesToLogsV2: # If you are going to link your tracing data with logs, configure <<tracesToLogsV2>> | ||
datasourceUid: 'loki' | ||
spanStartTimeShift: '-2m' | ||
spanEndTimeShift: '2m' | ||
filterByTraceID: true | ||
filterBySpanID: true | ||
serviceMap: # If you are going to add serviceGraph feature to tempo, configure <<serviceMap.datasourceUid>> | ||
datasourceUid: 'Mimir-OtelMetrics-Tenant' | ||
nodeGraph: # If you are going to add nodeGraph feature to tempo, enable <<nodeGraph>> | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import List, Optional | ||
from pydantic import BaseModel, validator, ValidationError | ||
|
||
class BasicAuth(BaseModel): | ||
basicAuthUser:str | ||
basicAuthPassword:str | ||
|
||
|
||
class AlertManagerInput(BaseModel): | ||
name:str = "Alertmanager" | ||
url:str = "http://localhost:9093" | ||
uid:str = "alertmanager" | ||
implementation:str | ||
|
||
handleGrafanaManagedAlerts:bool = True | ||
editable: bool = True | ||
basic_auth:Optional[BasicAuth] | ||
|
||
@validator("implementation") | ||
def validator_implementation(cls,value): | ||
valid = ['prometheus','cortex','mimir'] | ||
if value not in valid: | ||
raise ValueError(f"implementation must be in {valid}") | ||
return value | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from typing import List, Optional | ||
from pydantic import BaseModel, validator, ValidationError | ||
|
||
|
||
|
||
class ElasticSearchInput(BaseModel): | ||
name:str = "elasticsearch-v7-filebeat" | ||
url:str = "http://localhost:9200" | ||
editable: bool = True | ||
index:str = "[filebeat-]YYYY.MM.DD" | ||
interval:str = "Daily" | ||
timeField:str = "@timestamp" | ||
logMessageField:str = "message" | ||
logLevelField:str = "fields.level" | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from typing import List, Optional | ||
from pydantic import BaseModel, validator, ValidationError | ||
|
||
class BasicAuth(BaseModel): | ||
basicAuthUser:str | ||
basicAuthPassword:str | ||
|
||
class LokiInput(BaseModel): | ||
name:str = "Loki" | ||
uid:str = "loki" | ||
url:str = "http://localhost:3100" | ||
editable: bool = True | ||
timeout:int = 60 | ||
maxLines:int = 1000 | ||
basic_auth:Optional[BasicAuth] | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import List, Optional | ||
from pydantic import BaseModel, validator, ValidationError | ||
|
||
|
||
|
||
class MultiTenancy(BaseModel): | ||
tenant_name:str = "pods" | ||
httpHeaderName1:str = "X-Scope-OrgID" | ||
class MimirInput(BaseModel): | ||
name:str = "Mimir" | ||
uid:str = "mimir" | ||
url:str = "http://mimir-nginx.mimir.svc.cluster.local/prometheus" | ||
editable: bool = True | ||
alertmanagerUid:str = "alertmanager" | ||
multi_tenancy:Optional[MultiTenancy] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import List, Optional | ||
from pydantic import BaseModel, validator, ValidationError | ||
|
||
|
||
|
||
class TLS(BaseModel): | ||
tlsClientCert:str = "${GRAFANA_TLS_CLIENT_CERT}" | ||
tlsCACert:str = "${GRAFANA_TLS_CA_CERT}" | ||
tlsAuth:bool = True | ||
tlsSkipVerify:bool = True | ||
|
||
class MysqlInput(BaseModel): | ||
name:str = "MySQL" | ||
url:str = "localhost:3306" | ||
user:str = "grafana" | ||
editable: bool = True | ||
database:str = "grafana" | ||
maxOpenConns:int = 100 | ||
maxIdleConns:int = 100 | ||
maxIdleConnsAuto:bool = True | ||
connMaxLifetime:int = 14400 | ||
password:str = "${GRAFANA_MYSQL_PASSWORD}" | ||
tls :Optional[TLS] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import List, Optional | ||
from pydantic import BaseModel, validator, ValidationError | ||
|
||
|
||
|
||
|
||
class PostgresInput(BaseModel): | ||
name:str = "Postgres" | ||
url:str = "localhost:5432" | ||
user:str = "grafana" | ||
editable: bool = True | ||
database:str = "grafana" | ||
sslmode:str = "'disable'" | ||
password:str = "Password!" | ||
maxOpenConns:int = 100 | ||
maxIdleConns:int = 100 | ||
maxIdleConnsAuto:bool = True | ||
connMaxLifetime:int = 14400 | ||
postgresVersion:int = 903 | ||
timescaledb:bool = False | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import List, Optional | ||
from pydantic import BaseModel, validator, ValidationError,field_validator | ||
|
||
|
||
|
||
class PrometheusInput(BaseModel): | ||
name:str = "Prometheus" | ||
url:str = "http://localhost:9090" | ||
editable: bool = True | ||
httpMethod:str = "POST" | ||
manageAlerts:bool = True | ||
prometheusType:str = "Prometheus" | ||
prometheusVersion:str = "2.44.0" | ||
cacheLevel:str = "High" | ||
disableRecordingRules:bool = False | ||
incrementalQueryOverlapWindow:str = "10m" | ||
|
Oops, something went wrong.