我有一个非常简单的测试设置。数据流程如下:
sample.log -> Promtail -> Loki -> Grafana
我正在使用来自microsoft的日志文件:示例日志文件下载链接
我有promtail配置如下:
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: C:UsersuserDesktoptmppositions.yaml
clients:
- url: http://localhost:3100/loki/api/v1/push
scrape_configs:
- job_name: testing_logging_a_log_file
static_configs:
- targets:
- localhost
labels:
job: testing_logging_a_log_file_labels_job_what_even_is_this
host: testing_for_signs_of_life_probably_my_computer_name
__path__: C:UsersuserDesktopsample.log
- job_name: testing_logging_a_log_file_with_no_timestamp_test_2
static_configs:
- targets:
- localhost
labels:
job: actor_v2
host: ez_change
__path__: C:UsersuserDesktopActors_2.txt
洛基配置:
auth_enabled: false
server:
http_listen_port: 3100
ingester:
lifecycler:
address: 127.0.0.1
ring:
kvstore:
store: inmemory
replication_factor: 1
final_sleep: 0s
chunk_idle_period: 5m
chunk_retain_period: 30s
max_transfer_retries: 0
schema_config:
configs:
- from: 2018-04-15
store: boltdb
object_store: filesystem
schema: v11
index:
prefix: index_
period: 168h
storage_config:
boltdb:
directory: C:UsersuserDesktoptmplokiindex
filesystem:
directory: C:UsersuserDesktoptmplokichunks
limits_config:
enforce_metric_name: false
reject_old_samples: True
reject_old_samples_max_age: 168h
chunk_store_config:
max_look_back_period: 0s
table_manager:
retention_deletes_enabled: false
retention_period: 0s
第一次正确读取示例文件。我可以使用以下命令查询WARN日志:{host="testing_for_signs_of_life_probably_my_computer_name"} |= "WARN"
当我手动向sample.log
文件添加新的日志行时,出现了问题。(模拟写入文件的日志行)
2012-02-03 20:11:56 SampleClass3 [WARN] missing id 42334089511
这个新行在Grafana中不可见。要做到这一点,我必须知道什么特殊的配置吗?
这是一个网络问题,如果你删除了loki端口并且不配置任何网络,你可以通过在grafana面板中添加http://loki:3100来访问它。
是的,这很奇怪,当我添加一行到一个存在的日志文件,它不能在grafana探索中看到。但是…再试一次,再添加一行,现在前一行显示在grafana
中当你使用记事本时,它会发生,在notepad++上效果很好