|
| 1 | +local d = import 'doc-util/main.libsonnet'; |
| 2 | + |
| 3 | +local endpoint = { |
| 4 | + '#':: d.pkg(name='endpoint', url='', help='Endpoint is a helper to create endpoint configurations in ServiceMonitors. An endpoint defines a scrapeable endpoint serving Prometheus metrics.'), |
| 5 | + |
| 6 | + '#authorization':: d.obj(help='Authorization section for this endpoint'), |
| 7 | + authorization: { |
| 8 | + |
| 9 | + '#withType':: d.fn('Set the authentication type. Defaults to Bearer, Basic will cause an error', [d.arg('type', d.T.string)]), |
| 10 | + withType(type): { authorization+: { type: type } }, |
| 11 | + |
| 12 | + '#credentials':: d.obj(help="The secret's key that contains the credentials of the request"), |
| 13 | + credentials: { |
| 14 | + |
| 15 | + '#withKey':: d.fn('The key of the secret to select from. Must be a valid secret key.', [d.arg('key', d.T.string)]), |
| 16 | + withKey(key): { authorization+: { credentials+: { key: key } } }, |
| 17 | + |
| 18 | + '#withName':: d.fn('Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names', [d.arg('name', d.T.string)]), |
| 19 | + withName(name): { authorization+: { credentials+: { name: name } } }, |
| 20 | + |
| 21 | + '#withOptional':: d.fn('Specify whether the Secret or its key must be defined', [d.arg('is_optional', d.T.bool)]), |
| 22 | + withOptional(is_optional): { authorization+: { credentials+: { optional: is_optional } } }, |
| 23 | + }, |
| 24 | + }, |
| 25 | + |
| 26 | + '#withPort':: d.fn('Name of the service port this endpoint refers to. Mutually exclusive with withTargetPort.', [d.arg('port', d.T.string)]), |
| 27 | + withPort(port): { port: port }, |
| 28 | + |
| 29 | + '#withTargetPort':: d.fn('Name or number of the target port of the Pod behind the Service, the port must be specified with container port property. Mutually exclusive with withPort.', [d.arg('port', d.T.int)]), |
| 30 | + withTargetPort(port): { targetPort: port }, |
| 31 | + |
| 32 | + '#withPath':: d.fn('HTTP path to scrape for metrics.', [d.arg('path', d.T.string)]), |
| 33 | + withPath(path): { path: path }, |
| 34 | + |
| 35 | + '#withScheme':: d.fn('HTTP scheme to use for scraping.', [d.arg('scheme', d.T.string)]), |
| 36 | + withScheme(scheme): { scheme: scheme }, |
| 37 | + |
| 38 | + '#withParams':: d.fn('Optional HTTP URL parameters.', [d.arg('params', d.T.object)]), |
| 39 | + withParams(params): { params: params }, |
| 40 | + |
| 41 | + '#withInterval':: d.fn('Interval at which metrics should be scraped.', [d.arg('interval', d.T.string)]), |
| 42 | + withInterval(interval): { interval: interval }, |
| 43 | + |
| 44 | + '#withScrapeTimeout':: d.fn('Timeout after which the scrape is ended.', [d.arg('timeout', d.T.string)]), |
| 45 | + withScrapeTimeout(timeout): { scrapeTimeout: timeout }, |
| 46 | + |
| 47 | + '#tlsConfig':: d.obj('TLS configuration to use when scraping the endpoint'), |
| 48 | + tlsConfig: { |
| 49 | + '#ca':: d.obj('Struct containing the CA cert to use for the targets.'), |
| 50 | + ca: { |
| 51 | + '#secret':: d.obj('Secret containing data to use for the targets. Mutually exclusive with configMap.'), |
| 52 | + secret: { |
| 53 | + '#withKey':: d.fn('The key of the secret to select from. Must be a valid secret key.', [d.arg('key', d.T.string)]), |
| 54 | + withKey(key): { tlsConfig+: { ca+: { secret+: { key: key } } } }, |
| 55 | + |
| 56 | + '#withName':: d.fn('Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names', [d.arg('name', d.T.string)]), |
| 57 | + withName(name): { tlsConfig+: { ca+: { secret+: { name: name } } } }, |
| 58 | + |
| 59 | + '#withOptional':: d.fn('Specify whether the Secret or its key must be defined', [d.arg('is_optional', d.T.bool)]), |
| 60 | + withOptional(is_optional): { tlsConfig+: { ca+: { secret+: { optional: is_optional } } } }, |
| 61 | + }, |
| 62 | + |
| 63 | + '#configMap':: d.obj('ConfigMap containing data to use for the targets. Mutually exclusive with secret.'), |
| 64 | + configMap: { |
| 65 | + '#withKey':: d.fn('The key to select.', [d.arg('key', d.T.string)]), |
| 66 | + withKey(key): { tlsConfig+: { ca+: { configMap+: { key: key } } } }, |
| 67 | + |
| 68 | + '#withName':: d.fn('Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names', [d.arg('name', d.T.string)]), |
| 69 | + withName(name): { tlsConfig+: { ca+: { configMap+: { name: name } } } }, |
| 70 | + |
| 71 | + '#withOptional':: d.fn('Specify whether the ConfigMap or its key must be defined.', [d.arg('is_optional', d.T.bool)]), |
| 72 | + withOptional(is_optional): { tlsConfig+: { ca+: { configMap+: { optional: is_optional } } } }, |
| 73 | + }, |
| 74 | + }, |
| 75 | + |
| 76 | + '#cert':: d.obj('Struct containing the client cert file for the targets.'), |
| 77 | + cert: { |
| 78 | + '#secret':: d.obj('Secret containing data to use for the targets. Mutually exclusive with configMap.'), |
| 79 | + secret: { |
| 80 | + '#withKey':: d.fn('The key of the secret to select from. Must be a valid secret key.', [d.arg('key', d.T.string)]), |
| 81 | + withKey(key): { tlsConfig+: { cert+: { secret+: { key: key } } } }, |
| 82 | + |
| 83 | + '#withName':: d.fn('Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names', [d.arg('name', d.T.string)]), |
| 84 | + withName(name): { tlsConfig+: { cert+: { secret+: { name: name } } } }, |
| 85 | + |
| 86 | + '#withOptional':: d.fn('Specify whether the Secret or its key must be defined', [d.arg('is_optional', d.T.bool)]), |
| 87 | + withOptional(is_optional): { tlsConfig+: { cert+: { secret+: { optional: is_optional } } } }, |
| 88 | + }, |
| 89 | + |
| 90 | + '#configMap':: d.obj('ConfigMap containing data to use for the targets. Mutually exclusive with secret.'), |
| 91 | + configMap: { |
| 92 | + '#withKey':: d.fn('The key to select.', [d.arg('key', d.T.string)]), |
| 93 | + withKey(key): { tlsConfig+: { cert+: { configMap+: { key: key } } } }, |
| 94 | + |
| 95 | + '#withName':: d.fn('Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names', [d.arg('name', d.T.string)]), |
| 96 | + withName(name): { tlsConfig+: { cert+: { configMap+: { name: name } } } }, |
| 97 | + |
| 98 | + '#withOptional':: d.fn('Specify whether the ConfigMap or its key must be defined.', [d.arg('is_optional', d.T.bool)]), |
| 99 | + withOptional(is_optional): { tlsConfig+: { cert+: { configMap+: { optional: is_optional } } } }, |
| 100 | + }, |
| 101 | + }, |
| 102 | + |
| 103 | + '#keySecret':: d.obj('Secret containing the client key file for the targets.'), |
| 104 | + keySecret: { |
| 105 | + '#withKey':: d.fn('The key of the secret to select from. Must be a valid secret key.', [d.arg('key', d.T.string)]), |
| 106 | + withKey(key): { tlsConfig+: { keySecret+: { key: key } } }, |
| 107 | + |
| 108 | + '#withName':: d.fn('Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names', [d.arg('name', d.T.string)]), |
| 109 | + withName(name): { tlsConfig+: { keySecret+: { name: name } } }, |
| 110 | + |
| 111 | + '#withOptional':: d.fn('Specify whether the Secret or its key must be defined', [d.arg('is_optional', d.T.bool)]), |
| 112 | + withOptional(is_optional): { tlsConfig+: { keySecret+: { optional: is_optional } } }, |
| 113 | + }, |
| 114 | + |
| 115 | + '#withServerName':: d.fn('Used to verify the hostname for the targets.', [d.arg('name', d.T.string)]), |
| 116 | + withServerName(name): { tlsConfig+: { serverName: name } }, |
| 117 | + |
| 118 | + '#withInsecureSkipVerify':: d.fn('Disable target certificate validation.', [d.arg('skip_verify', d.T.bool)]), |
| 119 | + withInsecureSkipVerify(skip_verify): { tlsConfig+: { insecureSkipVerify: skip_verify } }, |
| 120 | + |
| 121 | + '#withCaFile':: d.fn('Path to the CA cert in the Prometheus container to use for the targets.', [d.arg('path', d.T.string)]), |
| 122 | + withCaFile(path): { tlsConfig+: { caFile: path } }, |
| 123 | + |
| 124 | + '#withCertFile':: d.fn('Path to the client cert file in the Prometheus container for the targets.', [d.arg('path', d.T.string)]), |
| 125 | + withCertFile(path): { tlsConfig+: { certFile: path } }, |
| 126 | + |
| 127 | + '#withKeyFile':: d.fn('Path to the client key file in the Prometheus container for the targets.', [d.arg('path', d.T.string)]), |
| 128 | + withKeyFile(path): { tlsConfig+: { keyFile: path } }, |
| 129 | + }, |
| 130 | + |
| 131 | + '#withBearerTokenFile':: d.fn('File to read bearer token for scraping targets.', [d.arg('path', d.T.string)]), |
| 132 | + withBearerTokenFile(path): { bearerTokenFile: path }, |
| 133 | + |
| 134 | + '#bearerTokenSecret':: d.obj('Secret to mount to read bearer token for scraping targets. The secret needs to be in the same namespace as the service monitor and accessible by the Prometheus Operator.'), |
| 135 | + bearerTokenSecret: { |
| 136 | + '#withKey':: d.fn('The key of the secret to select from. Must be a valid secret key.', [d.arg('key', d.T.string)]), |
| 137 | + withKey(key): { bearerTokenSecret+: { key: key } }, |
| 138 | + |
| 139 | + '#withName':: d.fn('Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names', [d.arg('name', d.T.string)]), |
| 140 | + withName(name): { bearerTokenSecret+: { name: name } }, |
| 141 | + |
| 142 | + '#withOptional':: d.fn('Specify whether the Secret or its key must be defined', [d.arg('is_optional', d.T.bool)]), |
| 143 | + withOptional(is_optional): { bearerTokenSecret+: { optional: is_optional } }, |
| 144 | + }, |
| 145 | + |
| 146 | + '#withHonorLabels':: d.fn('HonorLabels chooses the metric’s labels on collisions with target labels.', [d.arg('honor_labels', d.T.bool)]), |
| 147 | + withHonorLabels(honor_labels): { honorLabels: honor_labels }, |
| 148 | + |
| 149 | + '#withHonorTimestamps':: d.fn('HonorTimestamps controls whether Prometheus respects the timestamps present in scraped data.', [d.arg('honor_timestamps', d.T.bool)]), |
| 150 | + withHonorTimestamps(honor_timestamps): { honorTimestamps: honor_timestamps }, |
| 151 | + |
| 152 | + '#basicAuth':: d.obj('BasicAuth allow an endpoint to authenticate over basic authentication More info: https://prometheus.io/docs/operating/configuration/#endpoints'), |
| 153 | + basicAuth: { |
| 154 | + '#username':: d.obj('The secret in the service monitor namespace that contains the username for authentication.'), |
| 155 | + username: { |
| 156 | + '#withKey':: d.fn('The key of the secret to select from. Must be a valid secret key.', [d.arg('key', d.T.string)]), |
| 157 | + withKey(key): { basicAuth+: { username+: { key: key } } }, |
| 158 | + |
| 159 | + '#withName':: d.fn('Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names', [d.arg('name', d.T.string)]), |
| 160 | + withName(name): { basicAuth+: { username+: { name: name } } }, |
| 161 | + |
| 162 | + '#withOptional':: d.fn('Specify whether the Secret or its key must be defined', [d.arg('is_optional', d.T.bool)]), |
| 163 | + withOptional(is_optional): { basicAuth+: { username+: { optional: is_optional } } }, |
| 164 | + }, |
| 165 | + |
| 166 | + '#password':: d.obj('The secret in the service monitor namespace that contains the password for authentication.'), |
| 167 | + password: { |
| 168 | + '#withKey':: d.fn('The key of the secret to select from. Must be a valid secret key.', [d.arg('key', d.T.string)]), |
| 169 | + withKey(key): { basicAuth+: { password+: { key: key } } }, |
| 170 | + |
| 171 | + '#withName':: d.fn('Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names', [d.arg('name', d.T.string)]), |
| 172 | + withName(name): { basicAuth+: { password+: { name: name } } }, |
| 173 | + |
| 174 | + '#withOptional':: d.fn('Specify whether the Secret or its key must be defined', [d.arg('is_optional', d.T.bool)]), |
| 175 | + withOptional(is_optional): { basicAuth+: { password+: { optional: is_optional } } }, |
| 176 | + }, |
| 177 | + }, |
| 178 | + |
| 179 | + '#oauth2':: d.obj('OAuth2 for the URL. Only valid in Prometheus versions 2.27.0 and newer.'), |
| 180 | + oauth2: { |
| 181 | + '#clientId':: d.obj('The secret or configmap containing the OAuth2 client id.'), |
| 182 | + clientId: { |
| 183 | + '#secret':: d.obj('Secret containing data to use for the targets. Mutually exclusive with configMap.'), |
| 184 | + secret: { |
| 185 | + '#withKey':: d.fn('The key of the secret to select from. Must be a valid secret key.', [d.arg('key', d.T.string)]), |
| 186 | + withKey(key): { oauth2+: { clientId+: { secret+: { key: key } } } }, |
| 187 | + |
| 188 | + '#withName':: d.fn('Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names', [d.arg('name', d.T.string)]), |
| 189 | + withName(name): { oauth2+: { clientId+: { secret+: { name: name } } } }, |
| 190 | + |
| 191 | + '#withOptional':: d.fn('Specify whether the Secret or its key must be defined', [d.arg('is_optional', d.T.bool)]), |
| 192 | + withOptional(is_optional): { oauth2+: { clientId+: { secret+: { optional: is_optional } } } }, |
| 193 | + }, |
| 194 | + |
| 195 | + '#configMap':: d.obj('ConfigMap containing data to use for the targets. Mutually exclusive with secret.'), |
| 196 | + configMap: { |
| 197 | + '#withKey':: d.fn('The key to select.', [d.arg('key', d.T.string)]), |
| 198 | + withKey(key): { oauth2+: { clientId+: { configMap+: { key: key } } } }, |
| 199 | + |
| 200 | + '#withName':: d.fn('Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names', [d.arg('name', d.T.string)]), |
| 201 | + withName(name): { oauth2+: { clientId+: { configMap+: { name: name } } } }, |
| 202 | + |
| 203 | + '#withOptional':: d.fn('Specify whether the ConfigMap or its key must be defined.', [d.arg('is_optional', d.T.bool)]), |
| 204 | + withOptional(is_optional): { oauth2+: { clientId+: { configMap+: { optional: is_optional } } } }, |
| 205 | + }, |
| 206 | + }, |
| 207 | + |
| 208 | + '#clientSecret':: d.obj('The secret containing the OAuth2 client secret.'), |
| 209 | + clientSecret: { |
| 210 | + '#withKey':: d.fn('The key of the secret to select from. Must be a valid secret key.', [d.arg('key', d.T.string)]), |
| 211 | + withKey(key): { oauth2+: { clientSecret+: { key: key } } }, |
| 212 | + |
| 213 | + '#withName':: d.fn('Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names', [d.arg('name', d.T.string)]), |
| 214 | + withName(name): { oauth2+: { clientSecret+: { name: name } } }, |
| 215 | + |
| 216 | + '#withOptional':: d.fn('Specify whether the Secret or its key must be defined', [d.arg('is_optional', d.T.bool)]), |
| 217 | + withOptional(is_optional): { oauth2+: { clientSecret+: { optional: is_optional } } }, |
| 218 | + }, |
| 219 | + |
| 220 | + '#withTokenUrl':: d.fn('The URL to fetch the token from.', [d.arg('url', d.T.string)]), |
| 221 | + withTokenUrl(url): { oauth2+: { tokenUrl: url } }, |
| 222 | + |
| 223 | + '#withScopes':: d.fn('OAuth2 scopes used for the token request.', [d.arg('scopes', d.T.array)]), |
| 224 | + withScopes(scopes): { oauth2+: { scopes: scopes } }, |
| 225 | + |
| 226 | + '#withEndpointParams':: d.fn('Parameters to append to the token URL', [d.arg('params', d.T.object)]), |
| 227 | + withEndpointParams(params): { oauth2+: { endpointParams: params } }, |
| 228 | + }, |
| 229 | + |
| 230 | + '#withMetricRelabelings':: d.fn('MetricRelabelConfigs to apply to samples before ingestion.', [d.arg('relabelings', d.T.array)]), |
| 231 | + withMetricRelabelings(relabelings): { metricRelabelings: relabelings }, |
| 232 | + |
| 233 | + '#withRelabelings':: d.fn('RelabelConfigs to apply to samples before scraping. Prometheus Operator automatically adds relabelings for a few standard Kubernetes fields and replaces original scrape job name with __tmp_prometheus_job_name. More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config', [d.arg('relabelings', d.T.array)]), |
| 234 | + withRelabelings(relabelings): { relabelings: relabelings }, |
| 235 | + |
| 236 | + '#withProxyUrl':: d.fn('ProxyURL eg http://proxyserver:2195 Directs scrapes to proxy through this endpoint.', [d.arg('url', d.T.string)]), |
| 237 | + withProxyUrl(url): { proxyUrl: url }, |
| 238 | + |
| 239 | + '#mixin': 'ignore', |
| 240 | + mixin: self, |
| 241 | +}; |
| 242 | + |
| 243 | +{ |
| 244 | + monitoring+:: { |
| 245 | + v1+: { |
| 246 | + endpoint: endpoint, |
| 247 | + }, |
| 248 | + v1alpha1+: { |
| 249 | + endpoint: endpoint, |
| 250 | + }, |
| 251 | + }, |
| 252 | +} |
0 commit comments