Skip to content

Instantly share code, notes, and snippets.

@tanan
tanan / Gemfile
Last active January 15, 2018 08:27
source 'https://rubygems.org'
gem 'fluentd', '~>0.14.0'
gem 'fluent-plugin-bigquery', '~>1.1.1'
gem 'fluent-plugin-record-reformer', '~>0.8.3'
gem 'fluent-plugin-systemd', '~>0.0.8'
gem 'fluent-plugin-google-cloud', '~>0.6.12'
gem 'fluent-plugin-detect-exceptions', '~>0.0.8'
gem 'fluent-plugin-prometheus', '~>0.2.1'
gem 'fluent-plugin-multi-format-parser', '~>0.1.1'
spec:
containers:
- image: mysql:5.6
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql
key: password
kind: ConfigMap
apiVersion: v1
data:
containers.input.conf: |-
<source>
type tail
format json
time_key time
path /var/log/containers/*.log
pos_file /var/log/gcp-containers.log.pos
spec:
containers:
- name: fluentd-gcp
image: xxxx
volumeMounts:
- name: config-volume
mountPath: /etc/fluent/config.d
volumes:
- name: config-volume
configMap:
@tanan
tanan / main.go
Last active February 26, 2018 03:28
read arguments in main function.
a := kingpin.New(filepath.Base(os.Args[0]), "The Prometheus monitoring server")
a.Version(version.Print("prometheus"))
a.HelpFlag.Short('h')
a.Flag("config.file", "Prometheus configuration file path.").
Default("prometheus.yml").StringVar(&cfg.configFile)
a.Flag("web.listen-address", "Address to listen on for UI, API, and telemetry.").
@tanan
tanan / main.go
Created February 26, 2018 03:30
reload config file (prometheus.yml)
func reloadConfig(filename string, logger log.Logger, rls ...func(*config.Config) error) (err error) {
level.Info(logger).Log("msg", "Loading configuration file", "filename", filename)
defer func() {
if err == nil {
configSuccess.Set(1)
configSuccessTime.SetToCurrentTime()
} else {
configSuccess.Set(0)
}
@tanan
tanan / web.go
Created February 26, 2018 03:44
prometheus router setting
router.Get("/", func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, path.Join(o.ExternalURL.Path, "/graph"), http.StatusFound)
})
router.Get("/alerts", readyf(instrf("alerts", h.alerts)))
router.Get("/graph", readyf(instrf("graph", h.graph)))
router.Get("/status", readyf(instrf("status", h.status)))
router.Get("/flags", readyf(instrf("flags", h.flags)))
router.Get("/config", readyf(instrf("config", h.serveConfig)))
router.Get("/rules", readyf(instrf("rules", h.rules)))
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'kubernetes-apiservers'
kubernetes_sd_configs:
- role: endpoints
api_server: https://kubernetes.default
tls_config:
@tanan
tanan / role.yaml
Last active March 15, 2018 06:44
k8s ClusterRole setting
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: all-reader
rules:
- apiGroups:
- ""
resources:
- nodes
- nodes/proxy
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: prometheus
spec:
replicas: 1
selector:
matchLabels:
app: prometheus
template: