我正在尝试美化 aws 日志流
日志格式:
2022-09-07T17:14:35.987000+00:00 2022/09/07/[$LATEST]58f517bs4ebcsae033sd953bs734224 {"cold_start":true,"function_memory_size":512,"function_request_id":"a2cfdd5d-4b0b-4cfa-97c2-4af9ba6a1056","level":"ERROR","message":"Unexpected","sampling_rate":1,"timestamp":"2022-09-07T17:14:35.987Z","xray_trace_id":"1-6318d178-0e96c13a1399a74b4f353edd","extra":"{\"error\":\"AccessDeniedException: User: arn:aws:sts::\",\"stack\":\"AccessDeniedException: User: arn:aws:sts::\"}"}
Run Code Online (Sandbox Code Playgroud)
我想将其更改为
2022-09-07T17:14:35.987000+00:00 2022/09/07/[$LATEST]58f51004277b4ebcae033d953b734224 {
"cold_start": true,
"function_memory_size": 512,
"function_request_id": "a2cfdd5d-4b0b-4cfa-97c2-4af9ba6a1056",
"level": "ERROR",
"message": "Unexpected",
"sampling_rate": 1,
"timestamp": "2022-09-07T17:14:35.987Z",
"xray_trace_id": "1-6318d178-0e96c13a1399a74b4f353edd",
"extra": '{"error":"AccessDeniedException: User: arn:aws:sts::","stack":"AccessDeniedException: User: arn:aws:sts::"}',
}
Run Code Online (Sandbox Code Playgroud)
我试过这个
aws logs tail /aws/lambda/lambda-name | sed -u -e "s/\({.*}\)/$(echo \'\\1\' | jq)/"
Run Code Online (Sandbox Code Playgroud)
但我收到这个错误
parse error: Invalid numeric literal at line 2, column 0
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
您好,我有一个 kubernets 审核日志文件,扩展名为 . 日志文件包含 json 记录数据。我想解析过滤器中的记录。
以下是文件中的示例记录
{"kind":"Event","apiVersion":"audit.k8s.io/v1","level":"Metadata","auditID":"60cc3bf1-a04e-4db3-a343-98aaaea8c4a5","stage":"ResponseComplete","requestURI":"/api/v1/serviceaccounts?limit=500\u0026resourceVersion=0","verb":"list","user":{"username":"system:apiserver","uid":"7cded9c8-a35d-4e66-adf1-162ce37d5868","groups":["system:masters"]},"sourceIPs":["::1"],"userAgent":"kube-apiserver/v1.24.12 (linux/amd64) kubernetes/ef70d26","objectRef":{"resource":"serviceaccounts","apiVersion":"v1"},"responseStatus":{"metadata":{},"code":200},"requestReceivedTimestamp":"2023-04-06T15:10:46.594135Z","stageTimestamp":"2023-04-06T15:10:46.595016Z","annotations":{"authorization.k8s.io/decision":"allow","authorization.k8s.io/reason":""}}{"kind":"Event","apiVersion":"audit.k8s.io/v1","level":"Metadata","auditID":"1af73bde-3a0f-437d-a468-49da772d619d","stage":"ResponseComplete","requestURI":"/apis/batch/v1/namespaces/restricted-namespace/jobs?fieldManager=helm","verb":"create","user":{"username":"kubernetes-admin","groups":["system:masters","system:authenticated"]},"sourceIPs":["172.19.0.1"],"userAgent":"Go-http-client/2.0","objectRef":{"resource":"jobs","namespace":"restricted-namespace","name":"gateway-certgen","apiGroup":"batch","apiVersion":"v1"},"responseStatus":{"metadata":{},"code":201},"requestReceivedTimestamp":"2023-04-06T15:14:02.625749Z","stageTimestamp":"2023-04-06T15:14:02.632035Z","annotations":{"authorization.k8s.io/decision":"allow","authorization.k8s.io/reason":"","pod-security.kubernetes.io/audit-violations":"would violate PodSecurity \"restricted:v1.24\": allowPrivilegeEscalation != false (container \"certgen\" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container \"certgen\" must set securityContext.capabilities.drop=[\"ALL\"]), seccompProfile (pod or container \"certgen\" must set securityContext.seccompProfile.type to \"RuntimeDefault\" or \"Localhost\")"}}
Run Code Online (Sandbox Code Playgroud)
我想过滤掉这些记录并打印每个记录中以下字段的值。
.annotations.pod-security.kubernetes.io/audit-violations
Run Code Online (Sandbox Code Playgroud)
我正在使用这个命令,
cat kube-apiserver-audit.log | jq '.annotations."pod-security.kubernetes.io/audit-violations"'
Run Code Online (Sandbox Code Playgroud)
但是它给出了以下输出
null
null
"would violate PodSecurity \"restricted:v1.24\": allowPrivilegeEscalation != false (container \"certgen\" must set securityContext.allowPrivilegeEscalation=false), unrestricted capabilities (container \"certgen\" must set securityContext.capabilities.drop=[\"ALL\"]), seccompProfile (pod or container \"certgen\" must set securityContext.seccompProfile.type to …Run Code Online (Sandbox Code Playgroud) 我有一个大的2d数组,我序列化和base64_encode并扔进一个数据库.在另一个页面上,我将数组拉出来,当我输出base64_decode序列化数组时,我可以将其反射出去,它看起来确实有效.
但是,如果我尝试unserialize(base64_decode($serializedArray))它只是抛出相同的错误到几乎崩溃Firefox的点.
错误是:
警告:
unserialize()[function.unserialize]:第24行的/var/www/dev/wc_paul/inc/analyzerTester.php中不再存在节点
我会包含我回应的整个序列化数组,但是上次我在这个表单上尝试过它崩溃了我的Firefox.
有谁知道为什么会发生这种情况?
我想为某些CatalogProductId禁用DiscountPercentageMRC/NRC/Usage列.请在网格下面找到javascript.任何帮助将不胜感激.
<h2>Kendo Grid bound to ASP.NET MVC action methods</h2>
@* The DIV where the Kendo grid will be initialized *@
<div id="grid"></div>
<script>
$(document).ready(function () {
$("#grid").kendoGrid({
columns: [
{ field: "CompanyId"},
{ field: "CompanyName" },
{ field: "DiscountPercentageMRC" },
{ field: "CatalogProductId"},
{ field: "DiscountPercentageMRC" },
{ field: "DiscountPercentageNRC" },
{ field: "DiscountPercentageNRC" },
{ field: "DiscountPercentageUsage"}
],
height: 400,
editable: true, // enable editing
pageable: true,
sortable: true,
filterable: true,
toolbar: ["create", "save", "cancel","edit"], // specify toolbar commands …Run Code Online (Sandbox Code Playgroud) 不久前,我发现NSUserDefaults并思考:如果我能保留应用程序所需的信息NSUserDefaults,为什么还要创建数据库?这些是我的应用程序需要的变量:
NSUserDefaults作为使用数据库的替代方案有多适合?如果我使用NSUserDefaults而不是数据库,将所有"可购买"项目列为枚举是否合理?
我有一个哈希数组,在数组中有不同的键:
csv = [{:fruit=>"apple", :number=>23},{:age=>12,:name=>"XYZ"}]
Run Code Online (Sandbox Code Playgroud)
我如何得到这样的所有键:
[:fruit,:number,:age,:name]
Run Code Online (Sandbox Code Playgroud)
我试过了
array = csv.collect {|key,value| key }
Run Code Online (Sandbox Code Playgroud) 如果我的给定文件名已经在我的数据库中,我希望在我的表中更新,否则我想插入一个新行.我尝试这个代码,但EXISTS显示的错误请给我正确的方式,因为我更新在SQL中
public void SaveData(string filename, string jsonobject)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=;Integrated Security=True");
SqlCommand cmd;
SqlCommand cmda;
if EXISTS("SELECT * FROM T_Pages WHERE pagename = '" + filename + "") {
cmda = new SqlCommand("UPDATE T_Pages SET pagename='" + filename + "',pageinfo='" + jsonobject + "' WHERE pagename='" + filename + "'", con);
cmda.ExecuteNonQuery();
}
else {
cmd = new SqlCommand("insert into T_Pages (pagename,pageinfo) values('" + filename + "','" + jsonobject + "')", con);
cmd.ExecuteNonQuery(); …Run Code Online (Sandbox Code Playgroud) json数据:
{testId: '1' studentId:{'s1':{score: 20} 's2':{score: 80}}}
{testId: '2' studentId:{'s1':{score: 60} 's2':{score: 70}}}
{testId: '3' studentId:{'s5':{score: 40} 's7':{score: 30}}}
...
Run Code Online (Sandbox Code Playgroud)
我想用JQ告诉我每个测试有多少学生达到> x的分数.
因此对于上面的输入和x = 50,输出:
{testId: '1' numStudents:1}
{testId: '2' numStudents:2}
{testId: '3' numStudents:0}
Run Code Online (Sandbox Code Playgroud)
我能够生成一份列表,列出了每次考试成绩> 50的学生
{testId, studentId: .studentId[]?} | select(.studentId.score>50)
Run Code Online (Sandbox Code Playgroud)
此命令创建一个对象列表,其中每个对象包含testId,studentId和score,其中所有分数都大于50.但是我不知道如何将这些结果重新组合到我想要的输出中.
我有从 jq 中提取的字符串,我只想从中获取唯一值。
"a-b-c-v001"
"a-b-c-v002"
"a-b-c-v001"
"a-b-c-v003"
"a-b-c-v002"
Run Code Online (Sandbox Code Playgroud)
我只需要 3 个结果,独一无二
"a-b-c-v001"
"a-b-c-v002"
"a-b-c-v003"
Run Code Online (Sandbox Code Playgroud)
我试过 unique & sort 没有用 - https://jqplay.org/s/xjND6Iv60T
所以,我正在尝试导出一个来自api的环境变量,它返回json值.想使用jq只做一个衬垫,但如果值有空格我不能让它工作
尝试不包围引号中的值
/app/src $ $(echo '{"params":[{ "Name":"KEY","Value":"value with space"}]}' | jq
-r '.params[] | "export " + .Name + "=" + .Value')
/app/src $ printenv KEY
value
/app/src $
Run Code Online (Sandbox Code Playgroud)
接下来,我尝试将值包装在引号中
/app/src $ $(echo '{"params":[{ "Name":"KEY","Value":"value with space"}]}' | jq
-r '.params[] | "export " + .Name + "=\"" + .Value + "\""')
sh: export: space": bad variable name
/app/src $
Run Code Online (Sandbox Code Playgroud)