# 04.jq手册

# Linux安装

安装EPEL源

yum -y install epel-release
yum -y install jq
1
2

# 文档

1.jq 1.7 Manual (opens new window)

# 示例

  1. 过滤数据的长度,然后求p50、p95

head data_1_2.txt |jq -cr '{recordId:.recordId,cnlu:.cnlu,size:.cnlu|length} |select(.size>19) | .recordId,.size,.cnlu[.size0.5|floor].duration,.cnlu[.size0.95|floor].duration' |sed '{N;N;N;s/\n/,/g}'

{
    "nludispatch": {
        "duration": 114.00008201599
    },
    "maxnlu": [{
            "duration": 48.00009727478,
            "diff": 47.30429649353,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.168,
            "label": "2021042500000005",
            "tag": "hd-ack",
            "systime": 0.69580078125
        }
    ],
    "bcd": [{
            "duration": 114.00008201599,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.234,
            "tag": "hd"
        }
    ],
    "aios": [{
            "duration": 93.000173568726,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.213,
            "tag": "hd"
        }, {
            "duration": 114.00008201599,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.234,
            "tag": "hd"
        }
    ],
    "cnlu": [{
            "duration": 35.000085830688,
            "diff": 34.870203018188,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.155,
            "label": "2021042500000002",
            "tag": "hd-ack",
            "systime": 0.1298828125
        }, {
            "duration": 35.000085830688,
            "diff": 34.799158096313,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.155,
            "label": "2021042500000009",
            "tag": "hd-ack",
            "systime": 0.200927734375
        }, {
            "duration": 35.000085830688,
            "diff": 34.145105361938,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.155,
            "label": "2021042500000001",
            "tag": "user",
            "systime": 0.85498046875
        }, {
            "duration": 38.000106811523,
            "diff": 37.917098999023,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.158,
            "label": "2021092200000007",
            "tag": "hd-ack",
            "systime": 0.0830078125
        }, {
            "duration": 38.000106811523,
            "diff": 36.775253295898,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.158,
            "label": "2021071300000030",
            "tag": "hd-ack",
            "systime": 1.224853515625
        }, {
            "duration": 38.000106811523,
            "diff": 37.904159545898,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.158,
            "label": "2021051800000171",
            "tag": "hd-ack",
            "systime": 0.095947265625
        }, {
            "duration": 38.000106811523,
            "diff": 37.958114624023,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.158,
            "label": "2021102200000078",
            "tag": "hd-ack",
            "systime": 0.0419921875
        }, {
            "duration": 38.000106811523,
            "diff": 36.461288452148,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.158,
            "label": "2021071300000031",
            "tag": "hd-ack",
            "systime": 1.538818359375
        }, {
            "duration": 38.000106811523,
            "diff": 37.960067749023,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.158,
            "label": "2021042500000008",
            "tag": "hd-ack",
            "systime": 0.0400390625
        }, {
            "duration": 38.000106811523,
            "diff": 35.919296264648,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.158,
            "label": "2021041900000175",
            "tag": "hd-ack",
            "systime": 2.080810546875
        }, {
            "duration": 38.000106811523,
            "diff": 37.631942749023,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.158,
            "label": "2021052500000015",
            "tag": "hd-ack",
            "systime": 0.3681640625
        }, {
            "duration": 38.000106811523,
            "diff": 37.383163452148,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.158,
            "label": "2021042500000003",
            "tag": "user",
            "systime": 0.616943359375
        }, {
            "duration": 39.000034332275,
            "diff": 38.82205581665,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.159,
            "label": "2021082600000075",
            "tag": "hd-ack",
            "systime": 0.177978515625
        }, {
            "duration": 39.000034332275,
            "diff": 38.9700050354,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.159,
            "label": "2021073000000074",
            "tag": "hd-ack",
            "systime": 0.030029296875
        }, {
            "duration": 39.000034332275,
            "diff": 38.82596206665,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.159,
            "label": "2021102800000045",
            "tag": "hd-ack",
            "systime": 0.174072265625
        }, {
            "duration": 39.000034332275,
            "diff": 38.918003082275,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.159,
            "label": "2021072200000081",
            "tag": "hd-ack",
            "systime": 0.08203125
        }, {
            "duration": 39.000034332275,
            "diff": 38.293979644775,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.159,
            "label": "2021042500000007",
            "tag": "hd-ack",
            "systime": 0.7060546875
        }, {
            "duration": 42.00005531311,
            "diff": 41.719049453735,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.162,
            "label": "2021042500000004",
            "tag": "hd-ack",
            "systime": 0.281005859375
        }, {
            "duration": 48.00009727478,
            "diff": 35.74521446228,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.168,
            "label": "2021042500000010",
            "tag": "hd-ack",
            "systime": 12.2548828125
        }, {
            "duration": 48.00009727478,
            "diff": 47.30429649353,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.168,
            "label": "2021042500000005",
            "tag": "hd-ack",
            "systime": 0.69580078125
        }
    ],
    "aidui": [{
            "duration": 93.000173568726,
            "startTime": 1728378316.12,
            "resultTime": 1728378316.213,
            "tag": "hd"
        }
    ],
    "productId": "279601198",
    "requestId": "896292b2bf4b436882da642049e9a289",
    "recordId": "d2e0d703e2c14f8390731b2061ddb477:b9225bf5674f4b77bcd4739823186bc8:862a4c003abb47449c515ddd1f7ea840"
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
Last Updated: 10/11/2024, 12:55:32 PM
Apache License 2.0 | Copyright © 2022 by xueliang.wu 苏ICP备15016087号