-
Notifications
You must be signed in to change notification settings - Fork 371
/
grafanadatasource_types.go
267 lines (240 loc) · 13 KB
/
grafanadatasource_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/*
Copyright 2021.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
"fmt"
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// GrafanaDataSourceSpec defines the desired state of GrafanaDataSource
type GrafanaDataSourceSpec struct {
Datasources []GrafanaDataSourceFields `json:"datasources"`
Name string `json:"name"`
}
// GrafanaDatasourceStatus defines the observed state of GrafanaDatasource
type GrafanaDataSourceStatus struct {
Phase StatusPhase `json:"phase"`
Message string `json:"message"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// GrafanaDataSource is the Schema for the grafanadatasources API
type GrafanaDataSource struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec GrafanaDataSourceSpec `json:"spec,omitempty"`
Status GrafanaDataSourceStatus `json:"status,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// GrafanaDataSourceList contains a list of GrafanaDataSource
// +kubebuilder:object:root=true
type GrafanaDataSourceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []GrafanaDataSource `json:"items"`
}
type GrafanaDataSourceFields struct {
Name string `json:"name"`
Type string `json:"type"`
Uid string `json:"uid,omitempty"`
Access string `json:"access,omitempty"`
OrgId int `json:"orgId,omitempty"`
Url string `json:"url,omitempty"`
Password string `json:"password,omitempty"`
User string `json:"user,omitempty"`
Database string `json:"database,omitempty"`
BasicAuth bool `json:"basicAuth,omitempty"`
BasicAuthUser string `json:"basicAuthUser,omitempty"`
BasicAuthPassword string `json:"basicAuthPassword,omitempty"`
WithCredentials bool `json:"withCredentials,omitempty"`
IsDefault bool `json:"isDefault,omitempty"`
JsonData GrafanaDataSourceJsonData `json:"jsonData,omitempty"`
SecureJsonData GrafanaDataSourceSecureJsonData `json:"secureJsonData,omitempty"`
Version int `json:"version,omitempty"`
Editable bool `json:"editable,omitempty"`
}
// GrafanaDataSourceJsonData contains the most common json options
// See https://grafana.com/docs/administration/provisioning/#datasources
type GrafanaDataSourceJsonData struct {
OauthPassThru bool `json:"oauthPassThru,omitempty"`
TlsAuth bool `json:"tlsAuth,omitempty"`
TlsAuthWithCACert bool `json:"tlsAuthWithCACert,omitempty"`
TlsSkipVerify bool `json:"tlsSkipVerify,omitempty"`
GraphiteVersion string `json:"graphiteVersion,omitempty"`
TimeInterval string `json:"timeInterval,omitempty"`
EsVersion string `json:"esVersion,omitempty"`
TimeField string `json:"timeField,omitempty"`
Interval string `json:"interval,omitempty"`
LogMessageField string `json:"logMessageField,omitempty"`
LogLevelField string `json:"logLevelField,omitempty"`
AuthType string `json:"authType,omitempty"`
AssumeRoleArn string `json:"assumeRoleArn,omitempty"`
DefaultRegion string `json:"defaultRegion,omitempty"`
CustomMetricsNamespaces string `json:"customMetricsNamespaces,omitempty"`
TsdbVersion string `json:"tsdbVersion,omitempty"`
TsdbResolution string `json:"tsdbResolution,omitempty"`
Sslmode string `json:"sslmode,omitempty"`
Encrypt string `json:"encrypt,omitempty"`
PostgresVersion int `json:"postgresVersion,omitempty"`
Timescaledb bool `json:"timescaledb,omitempty"`
MaxOpenConns int `json:"maxOpenConns,omitempty"`
MaxIdleConns int `json:"maxIdleConns,omitempty"`
ConnMaxLifetime int `json:"connMaxLifetime,omitempty"`
// Useful fields for clickhouse datasource
// See https://github.com/Vertamedia/clickhouse-grafana/tree/master/dist/README.md#configure-the-datasource-with-provisioning
// See https://github.com/Vertamedia/clickhouse-grafana/tree/master/src/datasource.ts#L44
AddCorsHeader bool `json:"addCorsHeader,omitempty"`
DefaultDatabase string `json:"defaultDatabase,omitempty"`
UsePOST bool `json:"usePOST,omitempty"`
UseYandexCloudAuthorization bool `json:"useYandexCloudAuthorization,omitempty"`
XHeaderUser string `json:"xHeaderUser,omitempty"`
XHeaderKey string `json:"xHeaderKey,omitempty"`
// Custom HTTP headers for datasources
// See https://grafana.com/docs/grafana/latest/administration/provisioning/#datasources
HTTPHeaderName1 string `json:"httpHeaderName1,omitempty"`
HTTPHeaderName2 string `json:"httpHeaderName2,omitempty"`
HTTPHeaderName3 string `json:"httpHeaderName3,omitempty"`
HTTPHeaderName4 string `json:"httpHeaderName4,omitempty"`
HTTPHeaderName5 string `json:"httpHeaderName5,omitempty"`
HTTPHeaderName6 string `json:"httpHeaderName6,omitempty"`
HTTPHeaderName7 string `json:"httpHeaderName7,omitempty"`
HTTPHeaderName8 string `json:"httpHeaderName8,omitempty"`
HTTPHeaderName9 string `json:"httpHeaderName9,omitempty"`
// Fields for Stackdriver data sources
TokenUri string `json:"tokenUri,omitempty"`
ClientEmail string `json:"clientEmail,omitempty"`
AuthenticationType string `json:"authenticationType,omitempty"`
DefaultProject string `json:"defaultProject,omitempty"`
// Fields for Azure data sources
AppInsightsAppId string `json:"appInsightsAppId,omitempty"`
AzureLogAnalyticsSameAs string `json:"azureLogAnalyticsSameAs,omitempty"`
ClientId string `json:"clientId,omitempty"`
ClusterURL string `json:"clusterUrl,omitempty"`
CloudName string `json:"cloudName,omitempty"`
LogAnalyticsDefaultWorkspace string `json:"logAnalyticsDefaultWorkspace,omitempty"`
LogAnalyticsClientId string `json:"logAnalyticsClientId,omitempty"`
LogAnalyticsSubscriptionId string `json:"logAnalyticsSubscriptionId,omitempty"`
LogAnalyticsTenantId string `json:"logAnalyticsTenantId,omitempty"`
SubscriptionId string `json:"subscriptionId,omitempty"`
TenantId string `json:"tenantId,omitempty"`
// Fields for InfluxDB data sources
HTTPMode string `json:"httpMode,omitempty"`
Version string `json:"version,omitempty"`
Organization string `json:"organization,omitempty"`
DefaultBucket string `json:"defaultBucket,omitempty"`
// Fields for Loki data sources
MaxLines int `json:"maxLines,omitempty"`
DerivedFields []GrafanaDataSourceJsonDerivedFields `json:"derivedFields,omitempty"`
// Fields for Prometheus data sources
CustomQueryParameters string `json:"customQueryParameters,omitempty"`
HTTPMethod string `json:"httpMethod,omitempty"`
ExemplarTraceIdDestinations []GrafanaDataSourceJsonExemplarTraceIdDestinations `json:"exemplarTraceIdDestinations,omitempty"`
// Fields for tracing data sources
TracesToLogs GrafanaDataSourceJsonTracesToLogs `json:"tracesToLogs,omitempty"`
ServiceMap GrafanaDataSourceJsonServiceMap `json:"serviceMap,omitempty"`
NodeGraph GrafanaDatasourceJsonNodeGraph `json:"nodeGraph,omitempty"`
Search GrafanaDataSourceJsonSearch `json:"search,omitempty"`
// Fields for Github data sources
GithubUrl string `json:"githubUrl,omitempty"`
// Fields for Alertmanager data sources
Implementation string `json:"implementation,omitempty"`
// Fields for AWS Prometheus data sources
SigV4Auth bool `json:"sigV4Auth,omitempty"`
SigV4AuthType string `json:"sigV4AuthType,omitempty"`
SigV4ExternalId string `json:"sigV4ExternalId,omitempty"`
SigV4AssumeRoleArn string `json:"sigV4AssumeRoleArn,omitempty"`
SigV4Region string `json:"sigV4Region,omitempty"`
SigV4Profile string `json:"sigV4Profile,omitempty"`
// Fields for Instana data sources
// See https://github.com/instana/instana-grafana-datasource/blob/main/provisioning/datasources/datasource.yml
Url string `json:"url,omitempty"`
ApiToken string `json:"apiToken,omitempty"`
UseProxy bool `json:"useProxy,omitempty"`
ShowOffline bool `json:"showOffline,omitempty"`
AllowInfraExplore bool `json:"allowInfraExplore,omitempty"`
}
type GrafanaDataSourceJsonDerivedFields struct {
DatasourceUid string `json:"datasourceUid,omitempty"`
MatcherRegex string `json:"matcherRegex,omitempty"`
Name string `json:"name,omitempty"`
Url string `json:"url,omitempty"`
}
type GrafanaDataSourceJsonExemplarTraceIdDestinations struct {
DatasourceUid string `json:"datasourceUid,omitempty"`
Name string `json:"name,omitempty"`
Url string `json:"url,omitempty"`
UrlDisplayLabel string `json:"urlDisplayLabel,omitempty"`
}
type GrafanaDataSourceJsonTracesToLogs struct {
DatasourceUid string `json:"datasourceUid,omitempty"`
SpanEndTimeShift string `json:"spanEndTimeShift,omitempty"`
SpanStartTimeShift string `json:"spanStartTimeShift,omitempty"`
Tags []string `json:"tags,omitempty"`
FilterBySpanId bool `json:"filterBySpanID,omitempty"`
FilterByTraceID bool `json:"filterByTraceID,omitempty"`
LokiSearch bool `json:"lokiSearch,omitempty"`
}
type GrafanaDataSourceJsonServiceMap struct {
DatasourceUid string `json:"datasourceUid,omitempty"`
}
type GrafanaDataSourceJsonSearch struct {
Hide bool `json:"hide,omitempty"`
}
type GrafanaDatasourceJsonNodeGraph struct {
Enabled bool `json:"enabled,omitempty"`
}
// GrafanaDataSourceSecureJsonData contains the most common secure json options
// See https://grafana.com/docs/administration/provisioning/#datasources
type GrafanaDataSourceSecureJsonData struct {
TlsCaCert string `json:"tlsCACert,omitempty"`
TlsClientCert string `json:"tlsClientCert,omitempty"`
TlsClientKey string `json:"tlsClientKey,omitempty"`
Password string `json:"password,omitempty"`
BasicAuthPassword string `json:"basicAuthPassword,omitempty"`
AccessKey string `json:"accessKey,omitempty"`
SecretKey string `json:"secretKey,omitempty"`
// Custom HTTP headers for datasources
// See https://grafana.com/docs/grafana/latest/administration/provisioning/#datasources
HTTPHeaderValue1 string `json:"httpHeaderValue1,omitempty"`
HTTPHeaderValue2 string `json:"httpHeaderValue2,omitempty"`
HTTPHeaderValue3 string `json:"httpHeaderValue3,omitempty"`
HTTPHeaderValue4 string `json:"httpHeaderValue4,omitempty"`
HTTPHeaderValue5 string `json:"httpHeaderValue5,omitempty"`
HTTPHeaderValue6 string `json:"httpHeaderValue6,omitempty"`
HTTPHeaderValue7 string `json:"httpHeaderValue7,omitempty"`
HTTPHeaderValue8 string `json:"httpHeaderValue8,omitempty"`
HTTPHeaderValue9 string `json:"httpHeaderValue9,omitempty"`
// Fields for Stackdriver data sources
PrivateKey string `json:"privateKey,omitempty"`
// Fields for Azure data sources
ClientSecret string `json:"clientSecret,omitempty"`
AppInsightsApiKey string `json:"appInsightsApiKey,omitempty"`
LogAnalyticsClientSecret string `json:"logAnalyticsClientSecret,omitempty"`
// Fields for InfluxDB data sources
Token string `json:"token,omitempty"`
// Fields for Github data sources
AccessToken string `json:"accessToken,omitempty"`
// Fields for AWS data sources
SigV4AccessKey string `json:"sigV4AccessKey,omitempty"`
SigV4SecretKey string `json:"sigV4SecretKey,omitempty"`
}
func init() {
SchemeBuilder.Register(&GrafanaDataSource{}, &GrafanaDataSourceList{})
}
// Filename returns a unique per namespace key of the datasource
func (ds *GrafanaDataSource) Filename() string {
return fmt.Sprintf("%v_%v.yaml", ds.Namespace, strings.ToLower(ds.Name))
}