mirror of
https://github.com/wahyd4/home-docker.git
synced 2026-08-09 04:15:52 +10:00
Deploy telegraf to kubernetes
This commit is contained in:
@@ -53,3 +53,15 @@ kubectl -n apps create secret generic database-credentials --from-literal=passwo
|
||||
k apply -f pihole-pv.yaml -n home-apps
|
||||
|
||||
kubectl -n home-apps create secret generic pihole-admin-password --from-literal=webpassword=Uj2s3iUkRubkJs4
|
||||
|
||||
helm upgrade --install telegraf -f telegraf-values.yaml stable/telegraf -n home-apps
|
||||
|
||||
|
||||
### level=error ts=2020-06-25T14:19:22.581Z caller=klog.go:94 component=k8s_client_runtime func=ErrorDepth msg="/app/discovery/kubernetes/kubernetes.go:263: Failed to list *v1.Pod: pods is forbidden: User \"system:serviceaccount:default:default\" cannot list resource \"pods\" in API group \"\" in the namespace \"home-apps\""
|
||||
# https://github.com/coreos/prometheus-operator/blob/master/Documentation/user-guides/getting-started.md
|
||||
# service account
|
||||
|
||||
k apply -f prometheus-service-account.yaml -n default
|
||||
|
||||
# create service monitor for telegraf
|
||||
k apply -f telegraf-service-monitor.yaml -n default
|
||||
|
||||
@@ -72,36 +72,36 @@
|
||||
###############################################################################
|
||||
|
||||
# Configuration for influxdb server to send metrics to
|
||||
[[outputs.influxdb]]
|
||||
## The full HTTP or UDP endpoint URL for your InfluxDB instance.
|
||||
## Multiple urls can be specified as part of the same cluster,
|
||||
## this means that only ONE of the urls will be written to each interval.
|
||||
# urls = ["udp://localhost:8089"] # UDP endpoint example
|
||||
urls = ["http://influxdb:8086"] # required
|
||||
## The target database for metrics (telegraf will create it if not exists).
|
||||
database = "telegraf" # required
|
||||
# [[outputs.influxdb]]
|
||||
# ## The full HTTP or UDP endpoint URL for your InfluxDB instance.
|
||||
# ## Multiple urls can be specified as part of the same cluster,
|
||||
# ## this means that only ONE of the urls will be written to each interval.
|
||||
# # urls = ["udp://localhost:8089"] # UDP endpoint example
|
||||
# urls = ["http://influxdb:8086"] # required
|
||||
# ## The target database for metrics (telegraf will create it if not exists).
|
||||
# database = "telegraf" # required
|
||||
|
||||
## Retention policy to write to. Empty string writes to the default rp.
|
||||
retention_policy = ""
|
||||
## Write consistency (clusters only), can be: "any", "one", "quorum", "all"
|
||||
write_consistency = "any"
|
||||
# ## Retention policy to write to. Empty string writes to the default rp.
|
||||
# retention_policy = ""
|
||||
# ## Write consistency (clusters only), can be: "any", "one", "quorum", "all"
|
||||
# write_consistency = "any"
|
||||
|
||||
## Write timeout (for the InfluxDB client), formatted as a string.
|
||||
## If not provided, will default to 5s. 0s means no timeout (not recommended).
|
||||
timeout = "20s"
|
||||
username = "junv"
|
||||
password = "@wahyd4"
|
||||
## Set the user agent for HTTP POSTs (can be useful for log differentiation)
|
||||
# user_agent = "telegraf"
|
||||
## Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
|
||||
# udp_payload = 512
|
||||
# ## Write timeout (for the InfluxDB client), formatted as a string.
|
||||
# ## If not provided, will default to 5s. 0s means no timeout (not recommended).
|
||||
# timeout = "20s"
|
||||
# username = "junv"
|
||||
# password = "@wahyd4"
|
||||
# ## Set the user agent for HTTP POSTs (can be useful for log differentiation)
|
||||
# # user_agent = "telegraf"
|
||||
# ## Set UDP payload size, defaults to InfluxDB UDP Client default (512 bytes)
|
||||
# # udp_payload = 512
|
||||
|
||||
## Optional SSL Config
|
||||
# ssl_ca = "/etc/telegraf/ca.pem"
|
||||
# ssl_cert = "/etc/telegraf/cert.pem"
|
||||
# ssl_key = "/etc/telegraf/key.pem"
|
||||
## Use SSL but skip chain & host verification
|
||||
# insecure_skip_verify = false
|
||||
# ## Optional SSL Config
|
||||
# # ssl_ca = "/etc/telegraf/ca.pem"
|
||||
# # ssl_cert = "/etc/telegraf/cert.pem"
|
||||
# # ssl_key = "/etc/telegraf/key.pem"
|
||||
# ## Use SSL but skip chain & host verification
|
||||
# # insecure_skip_verify = false
|
||||
|
||||
|
||||
# # Configuration for Amon Server to send metrics to.
|
||||
@@ -469,9 +469,11 @@
|
||||
|
||||
|
||||
# # Configuration for the Prometheus client to spawn
|
||||
# [[outputs.prometheus_client]]
|
||||
# ## Address to listen on
|
||||
# # listen = ":9126"
|
||||
[[outputs.prometheus_client]]
|
||||
listen = ":9126"
|
||||
path = "/metrics"
|
||||
expiration_interval = "300s"
|
||||
string_as_label = true
|
||||
|
||||
|
||||
# # Configuration for the Riemann server to send metrics to
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: prometheus
|
||||
|
||||
---
|
||||
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: prometheus
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources:
|
||||
- nodes
|
||||
- nodes/metrics
|
||||
- services
|
||||
- endpoints
|
||||
- pods
|
||||
verbs: ["get", "list", "watch"]
|
||||
- apiGroups: [""]
|
||||
resources:
|
||||
- configmaps
|
||||
verbs: ["get"]
|
||||
- nonResourceURLs: ["/metrics"]
|
||||
verbs: ["get"]
|
||||
---
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: prometheus
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: prometheus
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: prometheus
|
||||
namespace: default
|
||||
@@ -0,0 +1,32 @@
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: telegraf
|
||||
labels:
|
||||
app: telegraf
|
||||
spec:
|
||||
namespaceSelector:
|
||||
matchNames:
|
||||
- home-apps
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/instance: telegraf
|
||||
app.kubernetes.io/name: telegraf
|
||||
endpoints:
|
||||
- port: prometheus-client
|
||||
interval: 30s
|
||||
---
|
||||
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: Prometheus
|
||||
metadata:
|
||||
name: prometheus
|
||||
spec:
|
||||
serviceAccountName: prometheus
|
||||
serviceMonitorSelector:
|
||||
matchLabels:
|
||||
app: telegraf
|
||||
resources:
|
||||
requests:
|
||||
memory: 100Mi
|
||||
enableAdminAPI: false
|
||||
@@ -0,0 +1,118 @@
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repo: "telegraf"
|
||||
tag: "1.14-alpine"
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
env:
|
||||
- name: HOSTNAME
|
||||
value: "telegraf-polling-service"
|
||||
|
||||
## Configure resource requests and limits
|
||||
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
|
||||
resources:
|
||||
requests:
|
||||
memory: 128Mi
|
||||
cpu: 100m
|
||||
limits:
|
||||
memory: 128Mi
|
||||
cpu: 100m
|
||||
|
||||
## Node labels for pod assignment
|
||||
## ref: https://kubernetes.io/docs/user-guide/node-selection/
|
||||
nodeSelector: {}
|
||||
|
||||
service:
|
||||
enabled: true
|
||||
type: ClusterIP
|
||||
annotations: {}
|
||||
|
||||
serviceAccount:
|
||||
# Specifies whether a ServiceAccount should be created
|
||||
create: true
|
||||
# The name of the ServiceAccount to use.
|
||||
# If not set and create is true, a name is generated using the fullname template
|
||||
name:
|
||||
|
||||
## Exposed telegraf configuration
|
||||
## For full list of possible values see `/docs/all-config-values.yaml` and `/docs/all-config-values.toml`
|
||||
## ref: https://docs.influxdata.com/telegraf/v1.1/administration/configuration/
|
||||
config:
|
||||
agent:
|
||||
interval: "30s"
|
||||
round_interval: true
|
||||
metric_batch_size: 1000
|
||||
metric_buffer_limit: 10000
|
||||
collection_jitter: "0s"
|
||||
flush_interval: "30s"
|
||||
flush_jitter: "0s"
|
||||
precision: ""
|
||||
debug: true
|
||||
quiet: false
|
||||
logfile: "/var/log/telegraf/client.log"
|
||||
hostname: "$HOSTNAME"
|
||||
omit_hostname: false
|
||||
processors:
|
||||
- enum:
|
||||
mapping:
|
||||
field: "status"
|
||||
dest: "status_code"
|
||||
value_mappings:
|
||||
healthy: 1
|
||||
problem: 2
|
||||
critical: 3
|
||||
outputs:
|
||||
- prometheus_client:
|
||||
listen: ":9126"
|
||||
path: /metrics
|
||||
expiration_interval: 300s
|
||||
string_as_label: true
|
||||
metric_version: 2
|
||||
inputs:
|
||||
- github:
|
||||
repositories:
|
||||
- wahyd4/work-in-australia
|
||||
- wahyd4/aria2-ariang-docker
|
||||
- wahyd4/aria2-ariang-x-docker-compose
|
||||
- wahyd4/knowledge-mind-mapping
|
||||
access_token: 6bc9a1aa2d8a13da59127d4184167acc84e7bbfa
|
||||
http_timeout: 10s
|
||||
- http:
|
||||
interval: "1800s"
|
||||
urls:
|
||||
- https://hub.docker.com/v2/repositories/wahyd4/
|
||||
method: GET
|
||||
# headers: {"User-Agent"= "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"}
|
||||
insecure_skip_verify: true
|
||||
timeout: 5s
|
||||
data_format: json
|
||||
json_query: results
|
||||
name_override: docker_hub
|
||||
tag_keys:
|
||||
- name
|
||||
json_string_fields:
|
||||
- name
|
||||
- http:
|
||||
interval: "1800s"
|
||||
urls:
|
||||
- https://api.waqi.info/feed/chengdu/us-consulate/?token=97578eb58bcfb3ddb7280af6c6cb75df9add8200
|
||||
- https://api.waqi.info/feed/chengdu/?token=97578eb58bcfb3ddb7280af6c6cb75df9add8200
|
||||
- https://api.waqi.info/feed/beijing/?token=97578eb58bcfb3ddb7280af6c6cb75df9add8200
|
||||
- https://api.waqi.info/feed/nanchong/?token=97578eb58bcfb3ddb7280af6c6cb75df9add8200
|
||||
- https://api.waqi.info/feed/neijiang/?token=97578eb58bcfb3ddb7280af6c6cb75df9add8200
|
||||
- https://api.waqi.info/feed/melbourne/?token=97578eb58bcfb3ddb7280af6c6cb75df9add8200
|
||||
method: GET
|
||||
# headers: {"User-Agent"= "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36"}
|
||||
insecure_skip_verify: true
|
||||
timeout: 10s
|
||||
data_format: json
|
||||
json_query: data
|
||||
name_override: air_index
|
||||
tag_keys:
|
||||
- city_name
|
||||
json_string_fields:
|
||||
- city_name
|
||||
json_time_key: time_s
|
||||
json_time_format: "2006-01-02 15:04:05"
|
||||
json_timezone: "Asia/Chongqing"
|
||||
Reference in New Issue
Block a user