美文网首页
聊聊被AI坑到的经历

聊聊被AI坑到的经历

作者: go4it | 来源:发表于2023-08-03 22:06 被阅读0次

本文主要介绍一下被AI坑到的经历

经历1

之前写聊聊如何自定义parallelStream的线程池这篇文章的时候,就被坑了一下。

起初我是搜索了一下,发现需要类似如下使用:

List<TodoTask> result = forkJoinPoolFactoryBean.getObject().submit(new Callable<List<TodoTask>>() {
            @Override
            public List<TodoTask> call() throws Exception {
                return IntStream.rangeClosed(1, 20).parallel().mapToObj(i -> {
                    log.info("thread:{}", Thread.currentThread().getName());
                    return new TodoTask(i, "name"+i);
                }).collect(Collectors.toList());
            }
        }).get();

这种方式总感觉不太优雅,而且也不太好直观看出来实现原理,在submit里头用parallel就可以了?

后来我用某gpt问了一下,给了如下答案,心想这个靠谱啊

IntStream.rangeClosed(1, 20).parallel().executor(customThreadPool).mapToObj(i -> {
                    log.info("thread:{}", Thread.currentThread().getName());
                    return new TodoTask(i, "name"+i);
                }).collect(Collectors.toList());

结果我等到打开ide,发现并没有executor方法,我想,是不是java8没有,是高版本的java才有,于是我用java20版本的打开看看,也没有,直呼上当了,不过这个因为有可运行的版本因而入坑不是很深。下面的经历2就是大坑了。

经历2

想用filebeat去收集日志,于是问ai: filebeat extract field from log seperate by |,回答如下

To extract fields from log files using Filebeat and separate them using the pipe symbol (|), you can use the grok processor in the Filebeat configuration file.

Here's an example of how you can configure Filebeat to collect log files and extract fields using the pipe symbol:

Open the Filebeat configuration file. The location of this file may vary depending on your system. Common locations include /etc/filebeat/filebeat.yml or /etc/filebeat/filebeat.yaml.

Find the filebeat.inputs section in the configuration file. This is where you define the log files to collect.

Add the following configuration for each log file you want to collect:

- type: log
  paths:
    - /path/to/your/logfile.log
  processors:
    - grok:
        patterns:
          - '%{WORD:field1}\|%{WORD:field2}\|%{WORD:field3}'
        field: "message"
In this example, replace /path/to/your/logfile.log with the actual path to your log file. The grok processor is used to extract fields from the log message using the pipe symbol (|). The patterns option specifies the grok pattern to use for field extraction, and the field option specifies the field to apply the processor to.

Save the configuration file and restart Filebeat for the changes to take effect.
With this configuration, Filebeat will collect the log file and extract fields from the log message using the pipe symbol (|). The extracted fields will be available in the output, and you can send them to Elasticsearch or any other output you have configured in Filebeat.

I hope this helps! Let me know if you have any further questions.

给出了grok来匹配,心想靠谱啊,想起了之前用logstash的时候好像用过grok,等我依葫芦画瓢写出了grok版本,一执行,发现报错filebeat error while initializing input: the processor action grok does not exist

于是我又搜索了半天,发现elastic论坛还在讨论给filebeat实现grok的processor,然后看了下官网,直呼上当了,filebeat现在还不支持grok,但是有dissect可以实现类似的功能

小结

还是不能过渡依赖ai,必须警惕ai回答的准确性,看来想借助ai来偷懒一会还是不行。我猜测ai是被错误的data给训练坏了,或者是没能完全理解上下文。

doc

相关文章

  • 被坑的经历

    10.22写作作业:笑来说:如果今天你不觉得昨天的你很傻逼,你就是没有进步。 复盘一两次自己被坑的经历(金钱、情感...

  • 那些被坑的经历

    我们家老王是一个程序员,最近辞职没有上班,在网上接单写程序做兼职。 最近遇到一个任务,是帮人找出一个已经写好的程序...

  • 工作被坑的经历

    今天和大家说一下自己找工作被坑的经历吧 我有一次找工作,遇到一个说是可以在家工作的,他让我加一个人的QQ,我加了,...

  • 迷坑

    每个人的心里可能因为基因或者成长经历会有很多“坑”,他们分别是“被爱坑”、“被认可坑”、“被看到坑”等等等等,有的...

  • 被亲戚坑过的经历

    这是我听妈妈讲的关于我太姥爷的故事。 我太姥爷小时候家境殷实,虽然算不上家资巨富,但也衣食不愁,在当地...

  • 买东西被坑的经历

    我正在剥玉米,老妈带着儿子买馄饨回来了。 我接过馄饨,和老妈聊着天,准备去做饭,转身看到儿子手里拿着一个黄色的陀螺...

  • beg

    被坑到吐血的人生

  • AI人工智能竟然还能做到这件事?

    近来,围绕应用人工智能的潜在益处和风险,正在经历激烈争论。从网络安全风险到所谓的“末日”机器,AI技术被认为,虽然...

  • 来自毕业学姐的忠告

    毕业半年多了,回想自己被坑的经历那简直是 惨(活)不(该)忍(被)睹(坑)。 1.毕业当天和朋友...

  • 与人相处,做不到这三点,很容易被坑

    相信每个人都有被人坑的经历吧,也是在与人相处的时候,稍微不注意,就可能被别人坑的很惨。那么为什么容易被坑呢? 相信...

网友评论

      本文标题:聊聊被AI坑到的经历

      本文链接:https://www.haomeiwen.com/subject/qvxvpdtx.html