Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
analyze_logs_by_rake
Search
namu
February 06, 2014
Technology
1
2.1k
analyze_logs_by_rake
ログ解析にRakeを使うことをオススメします
M3 Tech Talk #18 2014/01/31 #m3dev
namu
February 06, 2014
Tweet
Share
More Decks by namu
See All by namu
How To Create Chrome Extensions
namutaka
3
2.3k
Other Decks in Technology
See All in Technology
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
NW-JAWS #14 re:Invent 2024(予選落ち含)で 発表された推しアップデートについて
nagisa53
0
260
watsonx.ai Dojo #5 ファインチューニングとInstructLAB
oniak3ibm
PRO
0
160
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
330
Snowflake女子会#3 Snowpipeの良さを5分で語るよ
lana2548
0
230
ハイテク休憩
sat
PRO
2
140
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
240
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
20241220_S3 tablesの使い方を検証してみた
handy
3
370
AIのコンプラは何故しんどい?
shujisado
1
190
Wvlet: A New Flow-Style Query Language For Functional Data Modeling and Interactive Data Analysis - Trino Summit 2024
xerial
1
110
あの日俺達が夢見たサーバレスアーキテクチャ/the-serverless-architecture-we-dreamed-of
tomoki10
0
440
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.6k
A Philosophy of Restraint
colly
203
16k
4 Signs Your Business is Dying
shpigford
181
21k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Designing Experiences People Love
moore
138
23k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
510
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Become a Pro
speakerdeck
PRO
26
5k
Scaling GitHub
holman
458
140k
Transcript
Rake Ͱϩάղੳ M3 Teck Talk #18 2014.01.31 தଜوࢤ
Rakeͱ • make ͷruby൛ • JavaͰ͍͏ͱ͜Ζͷant • Rakefileͱ͍͏ϑΝΠϧ໊ͰλεΫΛఆٛ • rakeίϚϯυͰλεΫΛ࣮ߦ
rakeͷ֓ཁ • ʮRakefileʯͱ͍͏ϑΝΠϧ໊ͰॲཧΛهड़ • هࡌશͳRuby • taskϝιουͰλεΫΛఆٛ • ґଘؔΛఆٛͯ͠Ұ࿈ͷॲཧͷྲྀΕΛ࡞ΕΔ •
fileϝιουͰϑΝΠϧΛ࡞͢ΔλεΫΛఆٛ • ϑΝΠϧ͕͋ͬͨΓɺґଘ͢ΔϑΝΠϧΑΓ৽͚͠ΕεΩοϓ ͢Δ • shϝιουͰγΣϧίϚϯυΛ࣮ߦͰ͖Δ
؆୯ͳྫ͔Β
$ rake -P #λεΫҰཡ rake hello rake world hello !
$ rake hello # hello Λ࣮ߦ Hello ! $ rake world # worldΛ࣮ߦ Hello World ! $ rake file1.txt ˌfile1.txtΛ࡞ $ ls file1.txt ! $ cat file1.txt 11111 # Rakefile ! task :hello do puts "Hello" end ! task :world => [:hello] do puts "World" end ! file "file1.txt" do |t| sh "echo 1111 > #{t.name}" end
$ rake all.txt << create file1.txt >> complete file1.txt <<
create file2.txt echo 2222 > file2.txt >> complete file2.txt << create all.txt cat file1.txt file2.txt > all.txt >> complete all.txt ! $ cat file1.txt 1111 ! $ cat file2.txt 2222 ! $ cat all.txt 1111 2222 file "file1.txt" do |t| puts "<< create file1.txt" File.open(t.name, "w") do |file| file.puts("1111") end puts ">> complete file1.txt" end ! file "file2.txt" do |t| puts "<< create file2.txt" sh "echo 2222 > #{t.name}" puts ">> complete file2.txt" end ! file "all.txt" => ["file1.txt", "file2.txt"] do |t| ! puts "<< create all.txt" sh "cat #{t.prerequisites.join(' ')} > #{t.name}" puts ">> complete all.txt" end
RakeΛ͏͓͢͢ΊϙΠϯτ
͓͢͢ΊϙΠϯτ • RubyͰॻ͚Δ • ̍ͭͷλεΫΛখ͍͞ػೳʹɺґଘؔͰҰ࿈ͷྲྀΕΛ ࡞Δͱɺػೳ͝ͱʹ࣮ߦͰ͖ͯσόοά͍͢͠ • ಈ࡞֬ೝ༻ͷॲཧΛఆ͍ٛ͢͠ • ్தͰࢭΊ࣮ͯߦࡁΈͷfileλεΫεΩοϓͯ͠ɺଓ
͖͔Β࣮ߦͰ͖Δ
ฒྻ࣮ߦ
ฒྻ࣮ߦ file1.txt ࡞ file2.txt ࡞ all.txt࡞ ͜͜ฒྻͰ࣮ߦͰ͖Δ
Pwrake https://github.com/masa16/Pwrake/ • ฒྻ࣮ߦ൛rake • ͦͷ··ͷRakefileͰฒྻ࣮ߦ͕Ͱ͖Δ • ࢦఆͨ͠λεΫʹґଘ͢ΔλεΫ܈ΛεϨουͰฒྻԽ ! •
Πϯετʔϧํ๏ $ gem install pwrake • ͍ํ $ pwrake -j <ฒྻ> <λεΫ໊>
$ pwrake -j 2 all.txt << create file1.txt << create
file2.txt echo 2222 > file2.txt >> complete file1.txt >> complete file2.txt << create all.txt cat file1.txt file2.txt > all.txt >> complete all.txt file "file1.txt" do |t| puts "<< create file1.txt" File.open(t.name, "w") do |file| file.puts("1111") end puts ">> complete file1.txt" end ! file "file2.txt" do |t| puts "<< create file2.txt" sh "echo 2222 > #{t.name}" puts ">> complete file2.txt" end ! file "all.txt" => ["file1.txt", "file2.txt"] do |t| ! puts "<< create all.txt" sh "cat #{t.prerequisites.join(' ')} > #{t.name}" puts ">> complete all.txt" end
ϩάղੳͷ࣮ํ๏
ϩάղੳ access.01.log access.02.log access.03.log access.04.log result.01.csv result.02.csv result.03.csv result.04.csv result_all.csv
$ rake -P rake data/result.1.txt rake data/result.2.txt rake data/result.3.txt rake
data/result_all.log data/result.1.txt data/result.2.txt data/result.3.txt ! $ pwrake -j 2 run # # log/access.1.log => data/result.1.log # log/access.2.log => data/result.2.log # log/access.3.log => data/result.3.log # results = [] (1..3).each do |num| logfile = "data/result.#{num}.txt" results << logfile ! file logfile do |t| sh "grep 'iPad' log/access.#{num}.log > #{t.name}" end end ! # # data/result.1.log # data/result.2.log => data/result_all.log # data/result.3.log # file “data/result_all.log" => results do |t| sh "cat #{t.prerequisites.join(' ‘)} > #{t.name}" end ! task :run => [“data/result_all.log"]
͓·͚
Tips • fileλεΫͷλʔήοτ ͱ͢ΔϑΝΠϧɺॲཧ ͷ࠷ޙʹmvͰ࡞Δ • ్தͰఀࢭͨ͠ͱ͖ʹɺ ࡞Γ͔͚ϑΝΠϧ͕͋Δ ͨΊʹɺεΩοϓ͞Εͳ ͍Α͏ʹ͢ΔͨΊ
file “target.txt” do |t| ! sh “grep HOGE src.log > “ + “ #{t.name}.tmp “ ! sh “mv #{t.name}.tmp #{t.name}” end