How to model Cassandra DB for time series, server metrics

My name is Daniel, I'm a newbie, but a long time knight. I decided to learn Apache Cassandra for my next project, "Let write some code while the kids sleeping."

What I'm writing is a neat little api that will read and write against the cassandra database. I had a lot of db circuit computed in mongodb, but for me it is time to move on and grow as an engineer :)

Mission: I collect metrics from servers in my rack, the agent will send a payload every minute. I have an api part that pretty much computes will use JWT tokens that sign the payload. The type of data that I will store can be seen below. cpuload, cpuusage, memusage, discusage, etc.

The part where I got confused with cassandra is how to write the actual model, I understand that storagengines seems to write all this as a temporary series on disk for me, the creation reads quite surprisingly. I know that everything that I am going to beat now will work for my laboratory, since it is jsut 30 machines, but I’m trying to understand how all this is done correctly and how this can be done for a real-life scenario, such as server density , datadog, "insert preferred server monitoring". :)

But how are you more experienced engineers designing such a circuit?

Database Usage Scenarios:

  • download useful data through the api every minute. (let's imagine that at least 100 thousand writes per minute for the sake of learning something useful)
  • Read Asset Identity Assets

    • (3 )
    • ()
    • ()
    • ()
    • ..
  • PDF, ..

, , : timeuid | cpuusage

CREATE TABLE metrics(
    id uuid PRIMARY KEY,
    assetid int,
    serviceType text,
    metricValue int
)

CREATE TABLE metrics(
    id uuid PRIMARY KEY,
    assetid int,
    cpuload int,
    cpuusage int,
    memusage int,
    diskusage int,
)

mongo , . webgui avg .

. , .

URL- SO: Cassandra , , .

Sincerly

+1
1

:

CREATE TABLE metrics(
id uuid,
time timeuuid,
assetid int,
cpuload int,
cpuusage int,
memusage int,
diskusage int,
PRIMARY KEY (id, time) WITH CLUSTERING ORDER BY (time DESC))

, . LIMIT, :

SELECT * FROM metrics WHERE id = <UUID> LIMIT 60

:

SELECT * FROM metrics WHERE id = <UUID> LIMIT 1440

, , , , . , 3 , id :

CREATE TABLE metrics(
id uuid,
time timeuuid,
month text,
assetid int,
cpuload int,
cpuusage int,
memusage int,
diskusage int,
PRIMARY KEY ((id, month), time) WITH CLUSTERING ORDER BY (time DESC))

, + .

, . Cassandra , - . , .

, . , id . .

, , , assetid.

+1

Source: https://habr.com/ru/post/1687628/


All Articles