用 Perl 把 log 丟上 Slack

因為想在 Raspberry Pi 上面把一些 log 丟上 Slack,本來看到「Stream Any Log File to Slack Using curl」這篇,但發現裡面在把字串包進 JSON object 的方法太髒 (直接把 " 換成 '),另外一方面是 Slack 已經在宣導不要用舊版的 Incoming Webhooks,所以決定用其他方式來處理。

選擇 Perl 主要是因為有一陣子沒有用 Perl 寫東西了,倒不是什麼特別的原因 (如果考慮到 Raspberry Pi 上資源有限的話,應該用 C 或是 Rust 或是 Go,但我的 Raspberry Pi 還沒忙到這種程度...),所以決定用 Perl 來實做這個程式,把 log 檔案丟上 Slack:

這邊有些比較不太常見的選擇:

  • 不用 File::Tail 而反而是用 pipe 的方式取得 tail -F 的輸出,是因為 File::Tail 非常舊了 (2015),實做上沒有用到 inotify 類的界面監控檔案的變化,反而是系統的 tail 有做。
  • JSON::PP (pure perl 版本) 而不是 JSON 是因為 JSON::PP 在 Perl 5.14+ 後內建了,我沒有太在意效能,這也是上面放 use v5.14 的原因。
  • 這邊的 API 呼叫還是選擇了 WWW::Mechanize 是因為沒有內建的套件可以處理 HTTPS 連線 (可以參考 Perl core modules 這邊),既然要另外安裝,就裝個支援度比較完整的 libwww-mechanize-perl 來用。

然後查了一下 // 的用法在 Perl 5.10+ 就支援了,好早...

AWS Support 整合到 Slack 頻道內

在「New – AWS Support App in Slack to Manage Support Cases」這邊看到的新功能,主要是下面這張圖,看起來可以直接在 Slack 上面開 private channel 跟 AWS Support 成員討論事情:

依照說明,有 Business 以上的等級都可以用:

The AWS Support App in Slack is now available to all customers with Business, Enterprise On-ramp, or Enterprise Support at no additional charge.

雖然好像不是哪麼常跟 AWS 的人打交道,但平常先掛起來好像不錯...

Slack 宣佈漲價

Slack 宣佈了漲價的計畫:「Everything you need to know about our first price change and plan updates」。

從今年九月開始漲價,Pro 的月費從 US$8 漲到 US$8.75 (+9.375%),年費從 US$80 漲到 US$87 (+8.75%):

On September 1, 2022, monthly Pro plans will increase from $8 USD to $8.75 USD per user per month, and annual Pro plans will increase from $6.67 USD to $7.25 USD per user per month (pricing for other countries is available here).

現有用戶有一次用原價 renew 一年的機會:

Current customers on an annual Pro plan can lock in the existing annual rate of $6.67 USD per user per month for another year by early-renewing the annual Pro plan before September 1.

看起來八月底得來刷一下了...

Slack 在 2022/02/22 發生的 downtime 說明

Slack 針對今年年初的爆炸提出了說明:「Slack’s Incident on 2-22-22」,但真正的重點都在 Hacker News 的討論串上:「Slack’s Incident on 2-22-22 (slack.engineering)」。

大概有三件事情可以講,第一個是掛掉的原因,第二個是剛發出來的時候,一堆人對於標題用的「2-22-22」很感冒,第三個是剛剛 (一個小時前),Cal Henderson (Slack 的 CTO) 跑到 Hacker News 的討論串上回應...

Downtime 的部份

這次的 downtime 主要是發生在 Group Direct Message (GDM) 的部份:

A significant element of the datastore load appeared to be from a query that listed Group Direct Message (GDM) conversations by user. This operation is fronted by our cache tier, so the high query load seemed to indicate something was wrong with our caches.

這個 GDM 的查訊效率不高,而是靠 cache layer 撐住的,加上二月 22 日那天他們在更新 Consul 的 agent,導致 hit rate 的下降,以及遇到一個比較大的 peak time,接著就壓垮了資料庫。

oh,這中間還有 Vitess 一起進來打架,原文講的比較清楚,但需要花一些時間看。

2-22-22

剛發表出來的時候,其實大多數的討論反而是在討論「2-22-22」這件事情,這的確是很差的表示方法,尤其對於一份公告來說,不過這個問題本來就是個 flame war 等級的話題...

Slack CTO (Cal Henderson) 的回應

在重刷頁面的時候發現 iamcal 這個帳號的回應,而 Cal Henderson (Slack CTO) 的個人網站是 www.iamcal.com,雖然不確定這是不是本人帳號,但看起來之前在 2011 註冊後都沒動...

這個帳號回了兩個訊息,一個是提到 AWS 上其實很常看到 failure,需要靠本身架構的穩定性來撐:

Our underlying hardware (AWS) is nothing like this reliable. We see regular (several times a year) failure of racks of machines or whole DCs.

Across the whole fleet (all services), we lose 1-10 servers per day as a baseline. Major events are then on top of that and can impact thousand of hosts at once.

另外一個是反駁自以為的量級估算:

> Even the largest Slack instance probably has under 100,000 users and less than 1000 peak messages per second.

This is not true, by an order of magnitude.

好像還可以繼續在盯一下,不知道還會不會有回應...

Salesforce 買下 Slack

前陣子就有 Salesforce 要買下 Slack 的消息,剛剛確認了:「Salesforce buys Slack in a $27.7B megadeal」。

2019 年的時候花了 $15.3B 買下 Tableau (Salesforce bets on big data with $15.3 billion Tableau buy),這次則是 $27.7B...

從維基百科上翻了一下 Salesforce 手上買過的公司,看起來只有 Heroku 以及上面提到的 Tableau 比較熟悉...

這次併購對於 Slack 的人來說應該是好事?畢竟股價先漲了一波... 另外 Stewart Butterfield 不知道會再待多久,也許之後又會看到拉著 Cal Henderson 再幹一波?

回頭來看一下 Limelight Networks

是因為看到「How Limelight Networks speeds up sales deals with Slack Connect」這篇,才想到 Limelight Networks 這家 CDN 之前也是這個產業很大的 vendor,在很多大型網站可以看到 llnw 的蹤跡 (當時 Microsoft 的 Windows Updates 與 Apple 的軟體下載還會用他的服務),但這十年看起來就被 CloudflareCloudFront 以及 Fastly 這些後起之秀超越過去了... (至少在聲量上面是這樣)

翻到 Global Private Network 這頁,意外發現現在有把節點列出來了,記得以前是不公開的...

在裡面可以看到台灣也有節點,不過拿 HiNet 與 APOL (家裡的 cable) 實際測官網 www.limelight.com,發現都是導去香港的點,可能是有需要的客戶才會導過去,之後有機會也許問問看...

AWS Chatbot 支援 Slack

看到「AWS Chatbot now supports running commands from Slack (beta)」以及「Running AWS commands from Slack using AWS Chatbot」這篇文章,裡面提到了 AWS Chatbot 現在支援 Slack,本來是自己找 3rd-party software 接,現在包成服務了:

AWS Chatbot now supports running AWS commands and actions from Slack.

然後因為 AWS Chatbot 可以 invoke lambda,所以很多功能都可以用這個方法接起來:

You can retrieve diagnostic information, invoke Lambda functions and create AWS Support cases right from your Slack channels, so your team can collaborate and respond to events faster.

有些常用功能就直接放進內建功能了,像是讀 CloudWatch Logs:

In addition to running commands, you can also retrieve Amazon CloudWatch logs by simply clicking the “Show logs” button on CloudWatch Alarms notifications in Slack. AWS Chatbot supports actions for displaying logs for AWS Lambda and Amazon API Gateway.

不過因為權限系統沒有整合的關係,可以看到還是有很多權限的授權得由人工操作,而不是一鍵就全部授權完成...

Slack 改善桌面應用程式的效能與記憶體用量

Slack 桌面版改版的消息,在「Slack’s new desktop app loads 33 percent faster and uses less RAM」與「Slack speeds up its web and desktop client」這邊都有提到這兩個數字,不過看了官方的「When a rewrite isn’t: rebuilding Slack on the desktop」這篇,好像沒提到這兩個數字... 但看引用的圖片似乎是官方的評估數字,不知道是從哪邊得到的。

這是一個堅持繼續使用 Electron 的前提下改善效能的過程。如果過個幾年他們決定寫 native application 也不意外就是了,要一直壓榨效能,最後大概都會走到這邊... 當然也有可能靠 Google 一直改善 V8 engine 的效能撐很久 (畢竟 Google 是真狂砸人改善),現在大家都在賭可以改善多少 XD

這一波最主要的記憶體用量改善是來自於現在使用的 workspace 當然要有完整資料,而其他 workspace 的頁面就只保留狀態 (透過 Redux):

從記憶體用量可以看出來:

也可以理解因為這樣就不需要在啟動時馬上處理所有 workspace 的資料,所以啟動時間也就下降了不少,但這邊的 trade-off 是切換時的速度就會變慢 (需要重新 render),不過大概是考慮到常見情境下的切換次數而決定這樣做,應該還算 ok...

Slack 丟出 S-1 要 IPO...

最近一波 IPO 潮,現在輪到了 Slack

Form S-! 的資料可以在「slacks-1.htm」這邊抓到,裡面有些數字可以看看,懶的看的話可以看 TechCrunch 的整理:「Slack files to go public, reports $138.9M in losses on revenue of $400.6M」。

算是相當快的,2013 年八月到現在還不到六年...

Slack 收購 HipChat 與 Stride

雖然 Slack 這邊新聞稿的標題是「Atlassian + Slack」,不過不是直接買下 Atlassian,而是收購 Atlassian 下面的兩個產品,HipChatStride。另外 Atlassian 這邊的新聞稿在這:「Announcing our new partnership with Slack」。

HipChat 與 Stride 現有的使用者都會被轉移到 Slack,並且會終止這兩個產品線:

As part of this partnership, Atlassian will discontinue Hipchat and Stride, and provide a migration path to Slack for all their customers. We are purchasing the IP for Hipchat Cloud and Stride to better support that path to Slack, while Atlassian is making a small, but symbolically important investment in our business.

As part of this partnership, Atlassian has made an equity investment in Slack, and Slack has acquired the IP for Stride and Hipchat Cloud, both of which we will discontinue. We will also be discontinuing Hipchat Server and Hipchat Data Center and working with Slack to provide a migration path for customers of all four products.

對使用者算是好下場吧,至少不是被完全不相干的單位收購... (像是前幾天的「TRON 買下 BitTorrent Inc.」)