Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Loki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Loki
Commits
c74f0802
Commit
c74f0802
authored
6 years ago
by
yubozhao
Browse files
Options
Downloads
Patches
Plain Diff
Add documentation for different way to setup promtails
parent
351b4c69
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/promtail-setup.md
+164
-0
164 additions, 0 deletions
docs/promtail-setup.md
with
164 additions
and
0 deletions
docs/promtail-setup.md
0 → 100644
+
164
−
0
View file @
c74f0802
# Promtail Setups
## Daemonset method
Daemonset will deploy promtail on every node within the kubernetes cluster.
Daemonset deployment is great to collect all of the container logs within the
cluster. It is great solution for single tenant. All of the logs will send to a
single Loki server.
### Example
```
yaml
---Daemonset.yaml
apiVersion
:
extensions/v1beta1
kind
:
Daemonset
metadata
:
name
:
promtail-daemonset
...
spec
:
...
template
:
spec
:
serviceAccount
:
SERVICE_ACCOUNT
serviceAccountName
:
SERVICE_ACCOUNT
volumes
:
-
name
:
logs
hostPath
:
HOST_PATH
-
name
:
promtail-config
configMap
name
:
promtail-configmap
containers
:
-
name
:
promtail-container
args
:
-
-config.file=/etc/promtail/promtail.yaml
volumeMounts
:
-
name
:
logs
mountPath
:
MOUNT_PATH
-
name
:
promtail-config
mountPath
:
/etc/promtail
...
---configmap.yaml
apiVersion
:
v1
kind
:
ConfigMap
metadata
:
name
:
promtail-config
...
data
:
promtail.yaml
:
YOUR CONFIG
---Clusterrole.yaml
apiVersion
:
rbac.authorization.k8s.io/v1
kind
:
ClusterRole
metadata
:
name
:
promtail-clusterole
rules
:
-
apiGroups
:
resources
:
-
nodes
-
services
-
pod
verbs
:
-
get
-
watch
-
list
---ServiceAccount.yaml
apiVersion
:
v1
kind
:
ServiceAccount
metadata
:
name
:
promtail-serviceaccount
---Rolebinding
apiVersion
:
rbac.authorization.k9s.io/v1
kind
:
ClusterRoleBinding
metadata
:
name
:
promtail-clusterrolebinding
subjects
:
-
kind
:
ServiceAccount
name
:
promtail-serviceaccount
roleRef
:
kind
:
ClusterRole
name
:
promtail-clusterrole
apiGroup
:
rbac.authorization.k8s.io
```
## Sidecar Method
Sidecar method will deploy promtail as a container within a pod that
developer/devops create.
Sidecar method is good for logging for specific deployment/application. This
method works well in multi-tenant enviroment. This method also allow multiply
Loki servers receive logs from multiply promtail.
### Example
```
yaml
---Deployment.yaml
apiVersion
:
extensions/v1beta1
kind
:
Deployment
metadata
:
name
:
my_test_app
...
spec
:
...
template
:
spec
:
serviceAccount
:
SERVICE_ACCOUNT
serviceAccountName
:
SERVICE_ACCOUNT
volumes
:
-
name
:
logs
hostPath
:
HOST_PATH
-
name
:
promtail-config
configMap
name
:
promtail-configmap
containers
:
-
name
:
promtail-container
args
:
-
-config.file=/etc/promtail/promtail.yaml
volumeMounts
:
-
name
:
logs
mountPath
:
MOUNT_PATH
-
name
:
promtail-config
mountPath
:
/etc/promtail
...
...
```
### Custom Log Paths
Sometime application create customized log files. To collect those logs, you
would need to have a customized
`__path__`
in your scrap_config.
Right now, the best way to watch and tail custom log path is define log filepath
as a label for the pod.
#### Example
```
yaml
---Deployment.yaml
apiVersion
:
extensions/v1beta1
kind
:
Deployment
metadata
:
name
:
test-app-deployment
namespace
:
your_namespace
labels
:
logFileName
:
my_app_log
...
---promtail_config.yaml
...
scrap_configs
:
...
- job_name
:
job_name
kubernetes_sd_config
:
-
role
:
pod
relabel_config
:
...
-
action
:
replace
target_label
:
__path__
source_labes
:
-
__meta_kubernetes_pod_label_logFileName
replacement
:
/your_log_file_dir/$1.log
...
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment