Created
December 21, 2020 21:18
-
-
Save Ardagan/0203cf4441a5f4236e913dc211763271 to your computer and use it in GitHub Desktop.
Parse cassandra dump for test temporal metrics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl run --image=cassandra:3.11 --restart=Never --rm=true -it containername -- /bin/bash | |
---------------------------------- | |
/# cat /root/.cassandra/cqlshrc | |
[authentication] | |
username = <un> | |
password = <pwd> | |
[cql] | |
; Substitute for the version of Cassandra you are connecting to. | |
; version = 3.4.5 | |
[connection] | |
hostname = <host> | |
port = <port> | |
ssl=true | |
[ssl] | |
certfile = /ca.cert | |
userkey = /user.key | |
usercert = /user.cert | |
version = SSLv23 | |
; validate = true | |
; If using client authentication (require_client_auth = true in cassandra.yaml) you'll also need to point to your uesrkey and usercert. | |
; SSL client authentication is only supported via cqlsh on C* 2.1 and greater. | |
; This is disabled by default on all Instaclustr-managed clusters. | |
; userkey = /path/to/userkey.pem | |
; usercert = /path/to/usercert.pem | |
-------------------------------------------------------------- | |
kubectl exec --stdin --tty containername -- cqlsh --no-color -e "select json shard_id, type, namespace_id, workflow_id, run_id, current_run_id, task_id, next_event_id, range_id, activity_map from nightlytemporal.executions where type=1 allow filtering;" > test2.dump |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"encoding/json" | |
"fmt" | |
"log" | |
"os" | |
) | |
type executionInfo struct { | |
Shard_id uint64 `json:"shard_id"` | |
Ttype uint `json:"type"` | |
Namespace_id string `json:"namespace_id"` | |
Workflow_id string `json:"workflow_id"` | |
Run_id string `json:"run_id"` | |
Current_run_id string `json:"current_run_id"` | |
Task_id int `json:"task_id"` | |
Next_event_id int64 `json:"next_event_id"` | |
Range_id int `json:"range_id"` | |
Activity_map map[int64]interface{} `json:"activity_map"` | |
} | |
func main() { | |
file, err := os.Open("test2.json") | |
if (err != nil) { | |
log.Fatal(err) | |
} | |
defer file.Close() | |
scanner := bufio.NewScanner(file) | |
for scanner.Scan() { | |
line := scanner.Text() | |
var res executionInfo | |
error := json.Unmarshal([]byte(line), &res) | |
if error != nil { | |
fmt.Println(error) | |
continue | |
} | |
if (len(res.Activity_map) > 0) { | |
exists := false | |
for key, _ := range res.Activity_map { | |
if key > res.Next_event_id { | |
//if key > 10 { | |
exists = true | |
break | |
} | |
} | |
if exists { | |
fmt.Println(line) | |
fmt.Println(res) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment