Upgrade to Pro — share decks privately, control downloads, hide ads and more …

最近 Mackrel でやったこと

最近 Mackrel でやったこと

Hidekazu Tanaka

April 27, 2017
Tweet

More Decks by Hidekazu Tanaka

Other Decks in Technology

Transcript

  1. ࠷ۙ Mackerel Ͱ
    ΍ͬͨ͜ͱ
    2017.04.27 Mackerel Meetup #10
    Hidekazu Tanaka

    View full-size slide

  2. ࣗݾ঺հ
    • ాதल࿨
    • φϏϓϥεגࣜձࣾαʔϏε౷ׅ෦
    • ԼهαʔϏεͷ։ൃɾӡ༻ɾอक୲౰
    • NaviPlus Ϩίϝϯυ
    • NaviPlus ϨϏϡʔ

    View full-size slide

  3. ࣗݾ঺հ
    • ࡞੒ͨ͠ Mackerel ϓϥάΠϯ
    • mackerel-plugin-aws-waf
    • mackerel-plugin-aws-rekognition
    • mackerel-plugin-aws-kinesis-firehose

    View full-size slide

  4. Mackerel ͱ͍͑͹

    View full-size slide

  5. ៉ྷͳάϥϑ

    View full-size slide

  6. ៉ྷͳάϥϑͰ

    View full-size slide

  7. ͍Ζ͍Ζͳ΋ͷΛՄࢹԽʂ

    View full-size slide

  8. ՄࢹԽͨ͠΋ͷ
    • υϧԁͷϨʔτ
    • iPhone ͷϔϧεέΞσʔλ

    View full-size slide

  9. υϧԁͷϨʔτ

    View full-size slide

  10. खॱ
    1. Yahoo Finance ͔ΒυϧԁͷϨʔτΛऔಘ
    2. Mackerel ʹαʔϏεϝτϦοΫͱͯ͠౤ߘ

    View full-size slide

  11. ίʔυ
    #!/usr/bin/env ruby
    require 'mackerel'
    require 'yahoo-finance'
    MACKEREL_API_KEY = ''
    MACKEREL_SERVICE_NAME = ''
    yahoo_client = YahooFinance::Client.new
    data = yahoo_client.quote('USDJPY=X', [:ask, :bid, :last_trade_date, :last_trade_time])
    time = Time.strptime("#{data.last_trade_date} #{data.last_trade_time} +01:00", '%m/%d/
    %Y %H:%M%P %:z')
    mackerel_client = Mackerel::Client.new(mackerel_api_key: MACKEREL_API_KEY)
    mackerel_client.post_service_metrics(MACKEREL_SERVICE_NAME, [
    { name: 'finance.usdjpy.ask', time: time.to_i, value: data.ask.to_f },
    { name: 'finance.usdjpy.bid', time: time.to_i, value: data.bid.to_f }
    ])

    View full-size slide

  12. ੜ੒͞Εͨάϥϑ

    View full-size slide

  13. iPhone ͷϔϧεέΞσʔλ

    View full-size slide

  14. खॱ
    1. ʮHealth ExportʯͰา਺σʔλΛ CSV Խ
    2. CSV Λ iCloud Drive Ͱ macOS ʹసૹ
    3. macOS Ͱ CSV Λϩʔυ
    4. Mackerel ʹαʔϏεϝτϦοΫͱͯ͠౤ߘ

    View full-size slide

  15. ίʔυ
    #!/usr/bin/env ruby
    require 'csv'
    require 'mackerel'
    MACKEREL_API_KEY = ''
    MACKEREL_SERVICE_NAME = ''
    metrics = []
    CSV.foreach('./iphone_steps_date.csv', headers: true) do |row|
    metrics << {
    name: 'iphone.healthcare.steps',
    time: Time.strptime(row['time'], '%Y/%m/%d %H:%M').to_i,
    value: row['steps'].to_f
    }
    end
    Mackerel::Client.new(mackerel_api_key:
    MACKEREL_API_KEY).post_service_metrics(MACKEREL_SERVICE_NAME, metrics)

    View full-size slide

  16. ੜ੒͞Εͨάϥϑ

    View full-size slide

  17. ՄࢹԽͨ͠΋ͷ
    • υϧԁͷϨʔτ
    • iPhone ͷϔϧεέΞσʔλ

    View full-size slide

  18. ՄࢹԽ͍ͨ͠΋ͷ
    • Sentry ͷΠϕϯτൃੜ݅਺

    View full-size slide