小编Hem*_*dav的帖子

FluentD 日志不可读。它被排除在外,下次会检查

面对:流畅的日志不可读。它被排除在外,下次会检查

我对在 kubernetes 设置中运行的 fluentD 守护程序集有一个简单的配置。

Fluentd 版本:fluentd-0.12.43

下面是我的配置。

  <source>
    @type tail
    path /var/log/containers/sample*.log
    time_format %Y-%m-%dT%H:%M:%S.%NZ
    tag sample.*
    format json
    read_from_head true
  </source>
  <match sample.**>
    @type forward
    heartbeat_type tcp
    send_timeout 60s
    recover_wait 10s
    hard_timeout 60s
    <server>
      name worker-node2
      host 10.32.0.15
      port 24224
      weight 60
    </server>
  </match>
Run Code Online (Sandbox Code Playgroud)

低于警告并且没有转发日志

2018-08-03 06:36:53 +0000 [警告]:/var/log/containers/samplelog-79bd66868b-t7xn9_logging1_fluentd-70e85c5d6328e7d.log 不可读。它被排除在外,下次会检查。

2018-08-03 06:37:53 +0000 [警告]:/var/log/containers/samplelog-79bd66868b-t7xn9_logging1_fluentd-70e85c5bc89ab24.log 不可读。它被排除在外,下次会检查。

日志文件权限:

[root@k8s-master fluentd-daemonset]# ls -lrt **/var/log/containers/**

**lrwxrwxrwx** Jun 25 06:25 sample-77g68_kube-system_kube-proxy-9f3c3951c32ee.log 
-> /var/log/pods/aa1f8d5b-746f-11e8-95c0-005056b9ff3a/sample/7.log
Run Code Online (Sandbox Code Playgroud)

守护进程集的 YAML 文件有挂载说明:

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: …
Run Code Online (Sandbox Code Playgroud)

logging fluentd kubernetes

5
推荐指数
2
解决办法
5474
查看次数

只允许字符串中的某些字符。JavaScript

我不知道为什么这个简单的代码不起作用。我计划将字符串与允许的模式进行匹配。该字符串只能包含a-z, A-Z, 0-9, _(下划线), .(点), -(hiphen)。

下面是代码:

var profileIDPattern = /[a-zA-Z0-9_.-]./;
var str = 'Heman%t';
console.log('hemant',profileIDPattern.test(str));
Run Code Online (Sandbox Code Playgroud)

代码为以下字符串记录“true”,尽管这些字符串与模式不匹配。

'Heman%t' -> true
'#Hemant$' -> true
Run Code Online (Sandbox Code Playgroud)

我不知道是什么问题。

javascript regex pattern-matching

3
推荐指数
1
解决办法
3047
查看次数

使用 nlohmann json 解析 JSON

我正在尝试使用 nlohmann 的 json.hpp 解析 JSON 结构。但我不会从字符串创建 JSON 结构。我已经尝试了所有方法,但仍然失败。

我的要求是:

1) 从字符串创建 JSON 结构。

2)从中找到“statusCode”的值。

经过这么长时间的尝试,我真的很怀疑,nlohmann的json解析器是否支持嵌套JSON。

#include "json.hpp"
using namespace std;

int main(){

    // giving error 1
    nlohmann::json strjson = nlohmann::json::parse({"statusResp":{"statusCode":"S001","message":"Registration Success","snStatus":"Active","warrantyStart":"00000000","warrantyEnd":"00000000","companyBPID":"0002210887","siteBPID":"0002210888","contractStart":"00000000","contractEnd":"00000000"}});

    // Giving error 2:
   auto j= "{
    "statusResp": {
        "statusCode": "S001",
        "message": "Registration Success",
        "snStatus": "Active",
        "warrantyStart": "20170601",
        "warrantyEnd": "20270601",
        "companyBPID": "0002210887",
        "siteBPID": "0002210888",
        "contractStart": "00000000",
        "contractEnd": "00000000"
    }
   }"_json;

   // I actually want to get the value of "statusCode" code from the JSOn structure. But no idea …
Run Code Online (Sandbox Code Playgroud)

c++ json nlohmann-json jsonparser

0
推荐指数
1
解决办法
2万
查看次数