phanle1010 / binoculars Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
client
package is safe for calling concurrently by multiple goroutines. It is also safe to call start()
or stop()
on the same client object multiple times. Calling start()
on already started client or calling stop()
on already stopped()
client are no-op. Application can call start()
and stop()
the Binoculars client when users' consent is changed.[
{
"name": "storage_capacity",
"tags": {"instance_uuid": "123e4567-e89b-12d3-a456-426614174000"},
"fields": {"value": 1000000000000}
},
{
"name": "enabled_feature",
"tags": {"instance_uuid": "123e4567-e89b-12d3-a456-426614174000"},
"fields": {"node_selector": 1, "data_locality": 1}
}
]
RequestIntervalInMinutes
.Binoculars server creates a database with the name APPLICATION_NAME_binoculars
in the InfluxDB instance to store all related telemetrics for the users' application.
Parse the metric request
The Binoculars server receive the metrics in the following JSON format
[
{
"name": "storage_capacity",
"tags": {"instance_uuid": "123e4567-e89b-12d3-a456-426614174000"},
"fields": {"value": 1000000000000}
},
{
"name": "enabled_feature",
"tags": {"instance_uuid": "123e4567-e89b-12d3-a456-426614174000"},
"fields": {"node_selector": 1, "data_locality": 1}
}
]
The server parses the metrics and creates a point for each metric in the JSON request's body as follows:
name
is the name of measurement (table) of the point in the InfluxDBtags
are tags of the point in the InfluxDBfields
are fields of the point in the InfluxDBThe server then stores the points to the InfluxDB. With the above example request, the server stores 2 points in the InfluxDB:
> select * from storage_capacity
name: storage_capacity
time instance_uuid value
---- ------------- -----
1622017251731519223 123e4567-e89b-12d3-a456-426614174000 1000000000000
> select * from enabled_feature
name: enabled_feature
time auto_salvage data_locality instance_uuid
---- ------------ ------------- -------------
1622017251731530324 1 1 123e4567-e89b-12d3-a456-426614174000
The server returns the time duration that it wants the client to send the next metric update, RequestIntervalInMinutes
, in the response's body.
Now that we have the raw data in the storage_capacity
and enabled_feature
measurements, it is time for the application developers to use their InfluxDB expertise to get useful information out of the raw data.
Let's take a look at the enabled_feature
metric. The goal of this metric is so that the application developers can know which features of the application are most used and which features are not used so the developers can plan their development plan. In this example, assume that the query-period
is 1 hour so the Binoculars server is getting the updated metric from the client every hour.
First, create a continuous query that counts the number of each enabled feature every 1h
CREATE CONTINUOUS QUERY cq_enabled_feature_downsampling ON <APPLICATION_NAME>_binoculars
BEGIN
SELECT sum(*) INTO enabled_feature_downsampling
FROM enabled_feature
GROUP BY time(1h)
END
The following measurement is created in the InfluxDB (note that I changed the grouping time to 5 mins to save testing time)
> select * from enabled_feature_downsampling
name: enabled_feature_downsampling
time sum_auto_salvage sum_data_locality sum_node_selector sum_toleration
---- ---------------- ----------------- ----------------- --------------
1621971600000000000 1
1621971900000000000 3 4 3 1
1621973400000000000 2 6 4
1621978500000000000 4 8 3
1621978800000000000 6 9 8
1621979100000000000 6 6 6
1621979400000000000 11 14 5
<APPLICATION_NAME>_binoculars
in the InfluxDB instance.enabled_feature
metric from the previous section. In Grafana, the application developers can use this query to create a panel from the enabled_feature_downsampling
(Note that I actually group by 5m to save testing time):
SELECT last(*) FROM "enabled_feature_downsampling" WHERE $timeFilter GROUP BY time(1h) fill(null)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.