在Firebase数据库上创建各种指标的仪表板 [英] Create dashboard on Firebase Database for various metrics

查看:74
本文介绍了在Firebase数据库上创建各种指标的仪表板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Firebase数据库表中有events,其中每个事件都有某些字段.字段之一是event_type.我想要实现的是能够以图形化形式进行可视化显示,每种类型的事件每天发生多少次?

I have events in firebase database table where each event has certain fields. One of the field is event_type. What I want to achieve is to be able to visualize in graphical form, how many events of each type comes daily?

如何在Firebase数据库中执行类似的操作?

How do I do something like that in firebase database?

Q1.是否可以直接在Firebase中执行此操作?

Q1. Is it possible to directly do this in firebase?

Q2.我是否需要将数据移动到其他数据源(例如Big查询)并在那里设置仪表板?

Q2. Do I need to move data to some other datasource (like Big query) and setup dashboard there?

推荐答案

绝对有可能直接在Firebase实时数据库上创建带有聚合数据的仪表板.但是您必须采取与例如其他方法不同的方法BigQuery.

It is definitely possible to create a dashboard with aggregate data directly on the Firebase Realtime Database. But you'll have to take a different approach than with e.g. BigQuery.

对于关系数据库,您将通过运行聚合查询来创建仪表板.例如,要显示每种类型的事件数,您将运行类似SELECT type, COUNT(*) FROM events GROUP BY type的内容.

With relational databases, you'll create a dashboard by running aggregation queries. For example to show how many events of each type, you'll run something like SELECT type, COUNT(*) FROM events GROUP BY type.

Firebase实时数据库(和大多数NoSQL数据库)没有这样的GROUP BY操作,而不是COUNT()方法.因此,这意味着您必须将所有数据加载到仪表板中,并在那里进行分组/计数,这是非常昂贵的.因此,在NoSQL数据库上,您通常会为数据库中的每种类型保留运行计数,并在每次写入操作时对其进行更新.尽管这给每个写操作带来了额外的开销,但是当您执行此操作时,仪表板本身突然变得非常简单.有关简单计数器的示例,请参见功能样本存储库.

The Firebase Realtime Database (and most NoSQL databases) don't have such a GROUP BY operation, not a COUNT() method. So that means that you'd have to load all data into your dashboard, and group/count it there, which is quite expensive. That why on NoSQL databases you'll typically keep a running count for each type in the database and update that on every write operation. While this puts an overhead on each write operation, the dashboard itself suddenly becomes very simply when you do this. For an example of a simple counter, see the function-samples repo.

仅当您预先知道要在仪表板上显示哪些计数器(和其他汇总)时,此方法才有效.如果不是这种情况,许多开发人员将使用实时数据库的夜间备份将数据提取到另一个更适合探索性查询的系统中,例如BigQuery.

This approach only works if you know up front what counters (and other aggregates) you want to show in the dashboard. If that isn't the case, many developers use the nightly backups from the Realtime Database to ingest the data into another system that lends itself more to exploratory querying, such as BigQuery.

这两种方法都可以正常工作.正确的方法取决于您的确切用例(例如,您是否知道要在仪表板中找到的确切数据,还是仍在找出答案?)以及您最满意的情况.

Either approach can work fine. The right approach is a matter of your exact use-case (e.g. do you know the exact data you want in the dashboard, or are you still figuring that out?) and what you're most comfortable with.

这篇关于在Firebase数据库上创建各种指标的仪表板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆