loki

https://grafana.com/docs/loki/latest/installation/local/

InstallandrunLokilocallyInordertologeventswithLoki,youmustdownloadandinstallbothPromtailandLoki.Lokiistheloggingengine.PromtailsendslogstoLoki.InstallandrunNavigatetothereleasepage.ScrolldowntotheAssetssectionundertheversionthatyouwanttoinstall.DownloadtheLokiandPromtail.zipfilesthatcorrespondtoyoursystem.Note:DonotdownloadLogCLIorLokiCanaryatthistime.LogCLIallowsyoutorunLokiqueriesinacommandlineinterface.LokiCanaryisatooltoauditLokiperformance.Unzipthepackagecontentsintothesamedirectory.Thisiswherethetwoprogramswillrun.Inthecommandline,changedirectory(cdonmostsystems)tothedirectorywithLokiandPromtail.Copyandpastethecommandsbelowintoyourcommandlinetodownloadgenericconfigurationfiles:wgethttps://raw.githubusercontent.com/grafana/loki/master/cmd/loki/loki-local-config.yamlwgethttps://raw.githubusercontent.com/grafana/loki/master/cmd/promtail/promtail-local-config.yamlEnterthefollowingcommandtostartLoki:Windows.\loki-windows-amd64.exe--config.file=loki-local-config.yamlLinux./loki-linux-amd64-config.file=loki-local-config.yamlLokirunsanddisplaysLokilogsinyourcommandlineandonhttp://localhost:3100/metrics.Congratulations,Lokiisinstalledandrunning!Next,youmightwanteditthePromtailconfigfiletogetlogsintoLoki.Releasebinaries-openSUSELinuxonlyEveryreleaseincludesbinariesforLokiwhichcanbefoundontheReleasespage.CommunityopenSUSELinuxpackagesThecommunityprovidespackagesofLokiforopenSUSELinux.Toinstall:Addtherepositoryhttps://download.opensuse.org/repositories/security:/logging/ to your system. For example, if you are using Leap 15.1, run sudo zypper ar https://download.opensuse.org/repositories/security:/logging/openSUSE_Leap_15.1/security:logging.repo ; sudo zypper refInstalltheLokipackagewithzypperinlokiEnabletheLokiandPromtailservices:systemdstartloki&&systemdenablelokisystemdstartpromtail&&systemdenablepromtailModifytheconfigurationfilesasneeded:/etc/loki/promtail.yamland/etc/loki/loki.yaml.

$curl-O-L"https://github.com/grafana/loki/releases/download/v2.2.0/loki-linux-amd64.zip"#extractthebinary$unzip"loki-linux-amd64.zip"#makesureitisexecutable$chmoda+x"loki-linux-amd64"wgethttps://github.com/grafana/loki/releases/download/v2.2.0/promtail-linux-amd64.zip

GetlogsintoLokiAfteryouinstallandrunLoki,youprobablywanttogetlogsfromotherapplicationsintoit.TogetapplicationlogsintoLoki,youneedtoeditthePromtailconfigfile.DetailedinformationaboutconfiguringPromtailisavailableinPromtailconfiguration.Thefollowinginstructionsshouldhelpyougetstarted.Ifyouhaven’talready,downloadaPromtailconfigurationfile.Keeptrackofwhereitis,becauseyouwillneedtociteitwhenyourunthebinary.wgethttps://raw.githubusercontent.com/grafana/loki/master/cmd/promtail/promtail-local-config.yamlOpentheconfigfileinthetexteditorofyourchoice.Itshouldlooksimilartothis:server:http_listen_port:9080grpc_listen_port:0positions:filename:/tmp/positions.yaml`11111111111111111111111scrape_configs:-job_name:systemstatic_configs:-targets:-localhostlabels:job:varlogs__path__:/var/log/*logThe seven lines under scrape_configs are what send the logs that Loki generates to Loki, which then outputs them in the command line and http://localhost:3100/metrics.Copy the seven lines under scrape_configs, and then paste them under the original job (you can also just edit the original seven lines).Below is an example that sends logs from a default Grafana installation to Loki. We updated the following fields:job_name - This differentiates the logs collected from other log groups.targets - Optional for static_configs, however is often defined because in older versions of Promtail it was not optional. This was an artifact from directly using the Prometheus service discovery code which required this entry.labels - Static label to apply to every log line scraped by this definition. Good examples would be environment name, job name, or app name.path - The path to where the logs are stored that I want Loki to consume.- job_name: grafanastatic_configs:- targets:- grafanalabels:job: grafana__path__: "C:/Program Files/GrafanaLabs/grafana/data/log/grafana.log"Enter the following command to run Promtail. Examples below assume you have put the config file in the same directory as the binary.Windows`.\promtail-windows-amd64.exe --config.file=promtail-local-config.yaml`Linux./promtail-linux-amd64 -config.file=promtail-local-config.yamlYou should now see your application logs. If you are using Grafana, you might need to refresh your instance in order to see the logs.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市诬滩,隨后出現(xiàn)的幾起案子甥啄,更是在濱河造成了極大的恐慌邑彪,老刑警劉巖邀杏,帶你破解...
    沈念sama閱讀 206,968評論 6 482
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異拜秧,居然都是意外死亡搬味,警方通過查閱死者的電腦和手機(jī)萍恕,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,601評論 2 382
  • 文/潘曉璐 我一進(jìn)店門逸嘀,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人允粤,你說我怎么就攤上這事崭倘。” “怎么了类垫?”我有些...
    開封第一講書人閱讀 153,220評論 0 344
  • 文/不壞的土叔 我叫張陵司光,是天一觀的道長。 經(jīng)常有香客問我阔挠,道長飘庄,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 55,416評論 1 279
  • 正文 為了忘掉前任购撼,我火速辦了婚禮跪削,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘迂求。我一直安慰自己碾盐,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,425評論 5 374
  • 文/花漫 我一把揭開白布揩局。 她就那樣靜靜地躺著毫玖,像睡著了一般。 火紅的嫁衣襯著肌膚如雪凌盯。 梳的紋絲不亂的頭發(fā)上付枫,一...
    開封第一講書人閱讀 49,144評論 1 285
  • 那天,我揣著相機(jī)與錄音驰怎,去河邊找鬼阐滩。 笑死,一個(gè)胖子當(dāng)著我的面吹牛县忌,可吹牛的內(nèi)容都是我干的掂榔。 我是一名探鬼主播,決...
    沈念sama閱讀 38,432評論 3 401
  • 文/蒼蘭香墨 我猛地睜開眼症杏,長吁一口氣:“原來是場噩夢啊……” “哼装获!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起厉颤,我...
    開封第一講書人閱讀 37,088評論 0 261
  • 序言:老撾萬榮一對情侶失蹤穴豫,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后逼友,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體精肃,經(jīng)...
    沈念sama閱讀 43,586評論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡潘鲫,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,028評論 2 325
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了肋杖。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,137評論 1 334
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡挖函,死狀恐怖状植,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情怨喘,我是刑警寧澤津畸,帶...
    沈念sama閱讀 33,783評論 4 324
  • 正文 年R本政府宣布,位于F島的核電站必怜,受9級特大地震影響肉拓,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜梳庆,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,343評論 3 307
  • 文/蒙蒙 一暖途、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧膏执,春花似錦驻售、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,333評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至征峦,卻和暖如春迟几,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背栏笆。 一陣腳步聲響...
    開封第一講書人閱讀 31,559評論 1 262
  • 我被黑心中介騙來泰國打工类腮, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人竖伯。 一個(gè)月前我還...
    沈念sama閱讀 45,595評論 2 355
  • 正文 我出身青樓存哲,卻偏偏與公主長得像,于是被迫代替她去往敵國和親七婴。 傳聞我的和親對象是個(gè)殘疾皇子祟偷,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,901評論 2 345

推薦閱讀更多精彩內(nèi)容