美文网首页
使用 Cloudera 流处理进行欺诈检测-Part 1

使用 Cloudera 流处理进行欺诈检测-Part 1

作者: 大数据杂货铺 | 来源:发表于2022-11-14 11:47 被阅读0次

    <p data-mpa-powered-by="yiban.io" style="visibility: visible;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; visibility: visible;">在本系列的前一篇博客“</span>将流转化为数据产品<span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; visibility: visible;">”中,我们谈到了减少数据生成/摄取之间的延迟以及从这些数据中产生分析结果和洞察力的日益增长的需求。我们讨论了如何使用带有 Apache Kafka 和 Apache Flink 的</span>Cloudera 流处理<span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; visibility: visible;">(CSP) 来实时和大规模地处理这些数据。在这篇博客中,我们将展示一个真实的例子来说明如何做到这一点,看看我们如何使用 CSP 来执行实时欺诈检测。</span></p><p style="visibility: visible;">构建实时流分析数据管道需要能够处理流中的数据。流内处理的一个关键先决条件是能够收集和移动在源点生成的数据。这就是我们所说的第一英里问题。本博客将分两部分发布。在第一部分中,我们将研究由 Apache NiFi 提供支持的Cloudera DataFlow<strong style="visibility: visible;">如何通过轻松高效地获取</strong>、<strong style="visibility: visible;">转换</strong>和<strong style="visibility: visible;">移动</strong>数据来解决第一英里问题,以便我们可以轻松实现流分析用例。我们还将简要讨论在 Cloudera DataFlow 的云原生 Kubernetes 部署中运行此流程的优势。</p><p style="visibility: visible;">在第二部分中,我们将探讨如何使用 Apache Flink 运行实时流分析,我们将使用 Cloudera SQL Stream Builder GUI 仅使用 SQL 语言(无需 Java/Scala 编码)轻松创建流作业。我们还将使用流分析作业产生的信息来提供不同的下游系统和仪表板。 </p><section data-mpa-template="t" mpa-from-tpl="t" style="visibility: visible;"><h2 mpa-is-content="t" style="margin: 5px; padding-right: 10px; padding-left: 10px; font-weight: bold; max-width: 100%; font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; font-variant-numeric: normal; font-variant-east-asian: normal; letter-spacing: 0.544px; text-align: justify; white-space: normal; widows: 1; border-left: 5px solid rgb(2, 30, 170); line-height: 32px; background-color: rgb(255, 255, 255); border-top-color: rgb(2, 30, 170); border-bottom-color: rgb(2, 30, 170); border-right-color: rgb(2, 30, 170); box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;"><span style="color: rgb(136, 136, 136); border-color: rgb(2, 30, 170); visibility: visible;"><span style="color: rgb(2, 30, 170); border-color: rgb(2, 30, 170); visibility: visible;" mpa-is-content="t">用例</span></span></h2></section><p style="visibility: visible;"><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif; visibility: visible;">欺诈检测是我们探索的时间关键用例的一个很好的例子。我们都经历过这样一种情况,即我们的信用卡或我们认识的人的卡的详细信息已被泄露,并且非法交易被记入卡中。为了最大限度地减少这种情况下的损失,信用卡公司必须能够立即识别潜在的欺诈行为,以便它可以阻止信用卡并联系用户以验证交易,并可能发行一张新卡来替换受损的信用卡。</span></p><p style="visibility: visible;">卡交易数据通常来自事件驱动的来源,新数据随着现实世界中发生的卡购买而出现。除了流数据之外,我们还有传统的数据存储(数据库、键值存储、对象存储等),其中包含可能必须用于丰富流数据的数据。在我们的用例中,流数据不包含帐户和用户详细信息,因此我们必须将流与参考数据连接起来,以生成我们需要检查每个潜在欺诈交易的所有信息。</p><p>根据产生的信息的下游用途,我们可能需要以不同的格式存储数据:为 Kafka 主题生成潜在欺诈交易列表,以便通知系统可以立即采取行动;将统计数据保存在关系或操作仪表板中,以进行进一步分析或提供仪表板;或将原始交易流保存到持久的长期存储中,以供将来参考和进行更多分析。</p><p>我们在本博客中的示例将使用 Cloudera DataFlow 和 CDP 中的功能来实现以下内容:</p><p><img class="rich_pages wxw-img" data-backh="218" data-backw="578" data-ratio="0.3779296875" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbJeq0FT4EgRckZlSuytHGoicwzI6Acjq9Lo0vNxpQNe2YUD04nEqpdQg/640?wx_fmt=png" data-type="png" data-w="1024" style="width: 100%; height: auto; display: none;" data-index="1" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/a232b85ce8062370.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbJeq0FT4EgRckZlSuytHGoicwzI6Acjq9Lo0vNxpQNe2YUD04nEqpdQg/640?wx_fmt=png" data-index="1" style="width: 677px !important; height: 255.858px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><ol class="list-paddingleft-1"><li><p>Cloudera DataFlow 中的 Apache NiFi 将读取通过网络发送的交易流。</p></li><li><p>对于每笔交易,NiFi 都会调用 Cloudera 机器学习 (CML) 中的生产模型来评估交易的欺诈潜力。</p></li><li><p>如果欺诈分数高于某个阈值,NiFi 会立即将事务路由到通知系统订阅的 Kafka 主题,该主题将触发适当的操作。</p></li><li><p>评分的事务被写入 Kafka 主题,该主题将为在 Apache Flink 上运行的实时分析过程提供数据。</p></li><li><p>带有分数的交易数据也被保存到 Apache Kudu 数据库中,以供以后查询和提供欺诈仪表板。</p></li><li><p>使用 SQL Stream Builder (SSB),我们使用连续流式 SQL 来分析交易流,并根据购买的地理位置检测潜在的欺诈行为。</p></li><li><p>识别出的欺诈交易被写入另一个 Kafka 主题,该主题为系统提供必要的操作。</p></li><li><p>流式 SQL 作业还将欺诈检测保存到 Kudu 数据库。</p></li><li><p>来自 Kudu 数据库的仪表板提要显示欺诈摘要统计信息。</p></li></ol><h1></h1><section data-mpa-template="t" mpa-from-tpl="t"><h2 mpa-is-content="t" style="margin: 5px;padding-right: 10px;padding-left: 10px;font-weight: bold;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-variant-numeric: normal;font-variant-east-asian: normal;letter-spacing: 0.544px;text-align: justify;white-space: normal;widows: 1;border-left: 5px solid rgb(2, 30, 170);line-height: 32px;background-color: rgb(255, 255, 255);border-top-color: rgb(2, 30, 170);border-bottom-color: rgb(2, 30, 170);border-right-color: rgb(2, 30, 170);box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color:#888888;border-color: rgb(2, 30, 170);"><span style="color: rgb(2, 30, 170);border-color: rgb(2, 30, 170);" mpa-is-content="t">使用 Cloudera DataFlow 获取</span></span></h2></section><p><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">Apache NiFi 是 Cloudera DataFlow 的一个组件,可以轻松为您的用例获取数据并实施必要的管道来清理、转换和提供流处理工作流。凭借 300 多个开箱即用的处理器,它可用于执行</span>通用数据分发<span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">、获取和处理来自几乎任何类型的源或接收器的任何类型的数据。</span></p><p>在这个用例中,我们创建了一个相对简单的 NiFi 流程,它实现了上述步骤 1 到 5 的所有操作,我们将在下面更详细地描述这些操作。</p><p><img class="rich_pages wxw-img" data-backh="529" data-backw="578" data-ratio="0.9159802306425041" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenb1aJMOd7icibSynMQJT8c5r13GiarQCgMK7mGKwdUkEY8GMo0f9YbmyVvg/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="2" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/b26945ee04a222ce.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenb1aJMOd7icibSynMQJT8c5r13GiarQCgMK7mGKwdUkEY8GMo0f9YbmyVvg/640?wx_fmt=png" data-index="2" style="width: 677px !important; height: 620.119px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><p>在我们的用例中,我们正在处理来自外部代理的金融交易数据。该代理将每笔交易发送到一个网络地址。每笔交易都包含以下信息:</p><ul class="list-paddingleft-1"><li><p>交易时间戳</p></li><li><p>关联账户的ID</p></li><li><p>唯一的交易 ID</p></li><li><p>交易金额</p></li><li><p>交易发生地的地理坐标(经纬度)</p></li></ul><p>交易消息采用 JSON 格式,如下例所示:</p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="json"><code><span class="code-snippet_outer">{</span></code><code><span class="code-snippet_outer"></span></code><code><span class="code-snippet_outer"> <span class="code-snippet__attr">"ts"</span>: <span class="code-snippet__string">"2022-06-21 11:17:26"</span>,</span></code><code><span class="code-snippet_outer"></span></code><code><span class="code-snippet_outer"> <span class="code-snippet__attr">"account_id"</span>: <span class="code-snippet__string">"716"</span>,</span></code><code><span class="code-snippet_outer"></span></code><code><span class="code-snippet_outer"> <span class="code-snippet__attr">"transaction_id"</span>: <span class="code-snippet__string">"e933787c-f0ff-11ec-8cad-acde48001122"</span>,</span></code><code><span class="code-snippet_outer"></span></code><code><span class="code-snippet_outer"> <span class="code-snippet__attr">"amount"</span>: <span class="code-snippet__number">1926</span>,</span></code><code><span class="code-snippet_outer"></span></code><code><span class="code-snippet_outer"> <span class="code-snippet__attr">"lat"</span>: <span class="code-snippet__number">-35.40439536601375</span>,</span></code><code><span class="code-snippet_outer"></span></code><code><span class="code-snippet_outer"> <span class="code-snippet__attr">"lon"</span>: <span class="code-snippet__number">174.68080620053922</span></span></code><code><span class="code-snippet_outer"></span></code><code><span class="code-snippet_outer">}</span></code><code><span class="code-snippet_outer"></span></code></pre></section><p><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">NiFi 能够创建网络侦听器来接收来自网络的数据。对于这个例子,我们可以简单地将 ListenUDP 处理器拖放到 NiFi 画布中,并使用所需的端口对其进行配置。可以参数化处理器的配置以使流可重用。在这种情况下,我们定义了一个名为 #{input.udp.port} 的参数,稍后我们可以将其设置为我们需要的确切端口。</span></p><p><img class="rich_pages wxw-img" data-backh="269" data-backw="578" data-ratio="0.4645799011532125" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbSWAxulYibNDEuFNxq94TbrtzWwpbWfXpketzO0KAEQAVy6TmFCoa5Pg/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="3" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/a580c1ffcac64879.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbSWAxulYibNDEuFNxq94TbrtzWwpbWfXpketzO0KAEQAVy6TmFCoa5Pg/640?wx_fmt=png" data-index="3" style="width: 677px !important; height: 314.521px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><p><img class="rich_pages wxw-img" data-backh="405" data-backw="578" data-ratio="0.700164744645799" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbaR7rIbCY4tdJEgBp9N4r5Aj2ASrRmficIA6xoia8rT14rC6icqMr8fyDg/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="4" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/038078d760d1212b.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbaR7rIbCY4tdJEgBp9N4r5Aj2ASrRmficIA6xoia8rT14rC6icqMr8fyDg/640?wx_fmt=png" data-index="4" style="width: 677px !important; height: 474.012px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><h1></h1><section data-mpa-template="t" mpa-from-tpl="t"><h2 mpa-is-content="t" style="margin: 5px;padding-right: 10px;padding-left: 10px;font-weight: bold;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-variant-numeric: normal;font-variant-east-asian: normal;letter-spacing: 0.544px;text-align: justify;white-space: normal;widows: 1;border-left: 5px solid rgb(2, 30, 170);line-height: 32px;background-color: rgb(255, 255, 255);border-top-color: rgb(2, 30, 170);border-bottom-color: rgb(2, 30, 170);border-right-color: rgb(2, 30, 170);box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color:#888888;border-color: rgb(2, 30, 170);"><span style="color: rgb(2, 30, 170);border-color: rgb(2, 30, 170);" mpa-is-content="t">用Schema描述数据</span></span></h2></section><p><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">Schema是描述数据结构的文档。在环境中的多个应用程序甚至 NiFi 流中的处理器之间发送和接收数据时,拥有一个存储库非常有用,在该存储库中集中管理和存储所有不同类型数据的模式。这使应用程序更容易相互通信。</span></p><p>Cloudera 数据平台 (CDP) 带有 Schema Registry 服务。对于我们的示例用例,我们已将事务数据的模式存储在Schema Registry服务中,并将我们的 NiFi 流配置为使用正确的模式名称。NiFi 与 Schema Registry 集成,它会自动连接到它以在整个流程中需要时检索模式定义。</p><p><img class="rich_pages wxw-img" data-backh="219" data-backw="578" data-ratio="0.37891268533772654" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbrsfwmSkCB1TiavZ2I9jyRr7uXicwuib5U3G2PWt5JzngrLffFL9VExluA/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="5" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/1004f363771d41a0.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbrsfwmSkCB1TiavZ2I9jyRr7uXicwuib5U3G2PWt5JzngrLffFL9VExluA/640?wx_fmt=png" data-index="5" style="width: 677px !important; height: 256.524px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><p>数据在 NiFi 流中的路径由不同处理器之间的视觉连接决定。例如,在这里,ListenUDP 处理器先前接收到的数据被“标记”为我们要使用的模式的名称:“事务”。</p><p><img class="rich_pages wxw-img" data-backh="567" data-backw="578" data-ratio="0.9802306425041186" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenb5NdsIy5LsulOiaYKr6Mmia5vUBTDyU2nyaFhDsTFiaDQTfsTN5BnzLwrg/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="6" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/7cf9618cd613b6c4.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenb5NdsIy5LsulOiaYKr6Mmia5vUBTDyU2nyaFhDsTFiaDQTfsTN5BnzLwrg/640?wx_fmt=png" data-index="6" style="width: 677px !important; height: 663.616px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><h1></h1><section data-mpa-template="t" mpa-from-tpl="t"><h2 mpa-is-content="t" style="margin: 5px;padding-right: 10px;padding-left: 10px;font-weight: bold;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-variant-numeric: normal;font-variant-east-asian: normal;letter-spacing: 0.544px;text-align: justify;white-space: normal;widows: 1;border-left: 5px solid rgb(2, 30, 170);line-height: 32px;background-color: rgb(255, 255, 255);border-top-color: rgb(2, 30, 170);border-bottom-color: rgb(2, 30, 170);border-right-color: rgb(2, 30, 170);box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color:#888888;border-color: rgb(2, 30, 170);"><span style="color: rgb(2, 30, 170);border-color: rgb(2, 30, 170);" mpa-is-content="t">评分和路由交易</span></span></h2></section><p><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">我们使用 Cloudera 机器学习 (CML) 训练并构建了一个机器学习 (ML) 模型,以根据每笔交易的欺诈潜力对其进行评分。CML 提供了一个带有 REST 端点的服务,我们可以使用它来执行评分。当数据流经 NiFi 数据流时,我们希望调用数据点的 ML 模型服务来获取每个数据点的欺诈分数。</span></p><p>为此,我们使用 NiFi 的 LookupRecord,它允许针对 REST 服务进行查找。CML 模型的响应包含一个欺诈分数,由一个介于 0 和 1 之间的实数表示。</p><p>LookupRecord 处理器的输出,其中包含与 ML 模型的响应合并的原始交易数据,然后连接到 NiFi 中一个非常有用的处理器:QueryRecord 处理器。</p><p>QueryRecord 处理器允许您为处理器定义多个输出并将 SQL 查询与每个输出相关联。它将 SQL 查询应用于通过处理器流式传输的数据,并将每个查询的结果发送到相关的输出。</p><p>在此流程中,我们定义了三个 SQL 查询以在此处理器中同时运行:</p><p><img class="rich_pages wxw-img" data-backh="316" data-backw="578" data-ratio="0.5469522240527183" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenb2Nj9xd12q9R5VGRYFbTVAiaLaLQUs4Dlq2ZeHWRZVgDkgNfjXW2ibjlw/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="7" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/9fe9f6d835692f09.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenb2Nj9xd12q9R5VGRYFbTVAiaLaLQUs4Dlq2ZeHWRZVgDkgNfjXW2ibjlw/640?wx_fmt=png" data-index="7" style="width: 677px !important; height: 370.287px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><p><img class="rich_pages wxw-img" data-backh="237" data-backw="578" data-ratio="0.4102141680395387" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbNNPNQakfUibyUJzSapaRzz2iaTaj4WBYHLMPO8zAb3ynqQia9piaRocKLw/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="8" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/351a24782175854e.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbNNPNQakfUibyUJzSapaRzz2iaTaj4WBYHLMPO8zAb3ynqQia9piaRocKLw/640?wx_fmt=png" data-index="8" style="width: 677px !important; height: 277.715px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><p>请注意,某些处理器还定义了额外的输出,例如“失败”、“重试”等,以便您可以为流程定义自己的错误处理逻辑。</p><section data-mpa-template="t" mpa-from-tpl="t"><h2 mpa-is-content="t" style="margin: 5px;padding-right: 10px;padding-left: 10px;font-weight: bold;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-variant-numeric: normal;font-variant-east-asian: normal;letter-spacing: 0.544px;text-align: justify;white-space: normal;widows: 1;border-left: 5px solid rgb(2, 30, 170);line-height: 32px;background-color: rgb(255, 255, 255);border-top-color: rgb(2, 30, 170);border-bottom-color: rgb(2, 30, 170);border-right-color: rgb(2, 30, 170);box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color:#888888;border-color: rgb(2, 30, 170);"><span style="color: rgb(2, 30, 170);border-color: rgb(2, 30, 170);" mpa-is-content="t">将流送入其他系统</span></span></h2></section><p><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">在流程的这一点上,我们已经用 ML 模型的欺诈分数丰富了我们的流,并根据我们下游的需要转换了流。完成我们的数据摄取剩下的就是将数据发送到 Kafka,我们将使用它来提供我们的实时分析过程,并将事务保存到 Kudu 表,我们稍后将使用它来提供我们的仪表板,如以及其他非实时分析过程。</span></p><p>Apache Kafka 和 Apache Kudu 也是 CDP 的一部分,配置 Kafka 和 Kudu 特定的处理器来为我们完成任务非常简单。</p><p><img class="rich_pages wxw-img" data-backh="211" data-backw="578" data-ratio="0.3657331136738056" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbCAKfw0NFnKtsn7jibzpS5MxpzOImCoar8LmiaIsAEFB8ZUibqIGkhric7Q/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="9" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/c2c6380b4d46662c.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbCAKfw0NFnKtsn7jibzpS5MxpzOImCoar8LmiaIsAEFB8ZUibqIGkhric7Q/640?wx_fmt=png" data-index="9" style="width: 677px !important; height: 247.601px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><section data-mpa-template="t" mpa-from-tpl="t"><h2 mpa-is-content="t" style="margin: 5px;padding-right: 10px;padding-left: 10px;font-weight: bold;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-variant-numeric: normal;font-variant-east-asian: normal;letter-spacing: 0.544px;text-align: justify;white-space: normal;widows: 1;border-left: 5px solid rgb(2, 30, 170);line-height: 32px;background-color: rgb(255, 255, 255);border-top-color: rgb(2, 30, 170);border-bottom-color: rgb(2, 30, 170);border-right-color: rgb(2, 30, 170);box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color:#888888;border-color: rgb(2, 30, 170);"><span style="color: rgb(2, 30, 170);border-color: rgb(2, 30, 170);" mpa-is-content="t">在云上原生运行数据流</span></span></h2></section><p><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">构建 NiFi 流程后,它可以在您可能拥有的任何 NiFi 部署中执行。Cloudera DataFlow for the Public Cloud (CDF-PC) 提供了一个云原生弹性流运行时,可以高效地运行流。</span></p><p>与固定大小的 NiFi 集群相比,CDF 的云原生流运行时具有许多优势:</p><ul class="list-paddingleft-1"><li><p>您不需要管理 NiFi 集群。您可以简单地连接到 CDF 控制台,上传流定义并执行它。必要的 NiFi 服务会自动实例化为 Kubernetes 服务来执行流程,对用户透明。</p></li><li><p>它在流之间提供了更好的资源隔离。</p></li><li><p>流执行可以自动向上和向下扩展,以确保有适量的资源来处理当前正在处理的数据量。这避免了资源匮乏,并通过在不再使用时重新分配不必要的资源来节省成本。</p></li><li><p>具有用户定义的 KPI 的内置监控可以针对每个特定流进行定制,具有不同的粒度(系统、流、处理器、连接等)。</p></li></ul><h1></h1><section data-mpa-template="t" mpa-from-tpl="t"><h2 mpa-is-content="t" style="margin: 5px;padding-right: 10px;padding-left: 10px;font-weight: bold;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-variant-numeric: normal;font-variant-east-asian: normal;letter-spacing: 0.544px;text-align: justify;white-space: normal;widows: 1;border-left: 5px solid rgb(2, 30, 170);line-height: 32px;background-color: rgb(255, 255, 255);border-top-color: rgb(2, 30, 170);border-bottom-color: rgb(2, 30, 170);border-right-color: rgb(2, 30, 170);box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color:#888888;border-color: rgb(2, 30, 170);"><span style="color: rgb(2, 30, 170);border-color: rgb(2, 30, 170);" mpa-is-content="t">安全入站连接</span></span></h2></section><p><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">除了上述之外,将安全网络端点配置为入口网关是众所周知的云中难以解决的问题,并且每个云提供商的步骤各不相同。 </span></p><p>它需要设置负载平衡器、DNS 记录、证书和密钥库管理。 </p><p><img class="rich_pages wxw-img" data-backh="575" data-backw="578" data-ratio="0.9950576606260296" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbqBUnxKFs0SzjxkzCYBZkTHyNKXKh75O3mGUIDibxqzhOgUWVVFDdLMA/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="10" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/7e1eacb03149c5ca.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbqBUnxKFs0SzjxkzCYBZkTHyNKXKh75O3mGUIDibxqzhOgUWVVFDdLMA/640?wx_fmt=png" data-index="10" style="width: 677px !important; height: 673.654px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><p>CDF-PC 通过入站连接功能抽象出这些复杂性,允许用户通过提供所需的端点名称和端口号来创建入站连接端点。</p><p><img class="rich_pages wxw-img" data-backh="244" data-backw="578" data-ratio="0.42174629324546953" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenb30eQwGU6vwUSicgf4LSkqmo18EO83HEVQHEnEntiaIMDtdL1GALw5Xxg/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="11" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/a6ee70b74f4e4c2e.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenb30eQwGU6vwUSicgf4LSkqmo18EO83HEVQHEnEntiaIMDtdL1GALw5Xxg/640?wx_fmt=png" data-index="11" style="width: 677px !important; height: 285.522px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><h1></h1><section data-mpa-template="t" mpa-from-tpl="t"><h2 mpa-is-content="t" style="margin: 5px;padding-right: 10px;padding-left: 10px;font-weight: bold;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-variant-numeric: normal;font-variant-east-asian: normal;letter-spacing: 0.544px;text-align: justify;white-space: normal;widows: 1;border-left: 5px solid rgb(2, 30, 170);line-height: 32px;background-color: rgb(255, 255, 255);border-top-color: rgb(2, 30, 170);border-bottom-color: rgb(2, 30, 170);border-right-color: rgb(2, 30, 170);box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color:#888888;border-color: rgb(2, 30, 170);"><span style="color: rgb(2, 30, 170);border-color: rgb(2, 30, 170);" mpa-is-content="t">参数化和可定制的部署</span></span></h2></section><p><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">在流部署时,您可以定义流执行的参数,还可以选择流的大小和自动缩放特性:</span></p><p><img class="rich_pages wxw-img" data-backh="348" data-backw="578" data-ratio="0.6013179571663921" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenb1INvicBmuDDxXKQ2gCoTOr75nNrfdPWzVJ93tJ5cqqGaMJvn8d0l0bQ/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="12" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/23c349bf95173bfb.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenb1INvicBmuDDxXKQ2gCoTOr75nNrfdPWzVJ93tJ5cqqGaMJvn8d0l0bQ/640?wx_fmt=png" data-index="12" style="width: 677px !important; height: 407.092px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><section data-mpa-template="t" mpa-from-tpl="t"><h2 mpa-is-content="t" style="margin: 5px;padding-right: 10px;padding-left: 10px;font-weight: bold;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-variant-numeric: normal;font-variant-east-asian: normal;letter-spacing: 0.544px;text-align: justify;white-space: normal;widows: 1;border-left: 5px solid rgb(2, 30, 170);line-height: 32px;background-color: rgb(255, 255, 255);border-top-color: rgb(2, 30, 170);border-bottom-color: rgb(2, 30, 170);border-right-color: rgb(2, 30, 170);box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color:#888888;border-color: rgb(2, 30, 170);"><span style="color: rgb(2, 30, 170);border-color: rgb(2, 30, 170);" mpa-is-content="t">原生监控和警报</span></span></h2></section><p><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">可以定义自定义 KPI 来监控对您很重要的流程方面。还可以定义警报以在超过配置的阈值时生成通知:</span></p><p><img class="rich_pages wxw-img" data-backh="479" data-backw="578" data-ratio="0.828665568369028" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenb4q18D4gzETciaoKxJn6bsOZ8arhHmoIpkrjqd47ZEbPenFX5SCJ8Jqw/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="13" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/d9071de0e33f2ba6.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenb4q18D4gzETciaoKxJn6bsOZ8arhHmoIpkrjqd47ZEbPenFX5SCJ8Jqw/640?wx_fmt=png" data-index="13" style="width: 677px !important; height: 561.007px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><p>部署后,可以在 CDF 仪表板上监控为定义的 KPI 收集的指标:</p><p><img class="rich_pages wxw-img" data-backh="73" data-backw="578" data-ratio="0.12685337726523888" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbImD0icia14LqIb34qY93qgJdbZqtpS981cuhCWYHftqDG4xzG5me4XibQ/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="14" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/c17f718807fabcf0.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenbImD0icia14LqIb34qY93qgJdbZqtpS981cuhCWYHftqDG4xzG5me4XibQ/640?wx_fmt=png" data-index="14" style="width: 677px !important; height: 85.8797px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><p><img class="rich_pages wxw-img" data-backh="757" data-backw="578" data-ratio="1.3097199341021417" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenblbIsPQh23ib9ViaYqzkI8PtGXhpjKVXYrIHARBlQIeMh01YHT6K00iajA/640?wx_fmt=png" data-type="png" data-w="607" style="width: 100%; height: auto; display: none;" data-index="15" data-origin-display="" _width="100%" crossorigin="anonymous" alt="图片" src="https://img.haomeiwen.com/i13265002/17e1b049e0fd3f34.png"><span class="js_img_placeholder wx_widget_placeholder" data-src="https://mmbiz.qpic.cn/mmbiz_png/9IZsf6icv8GrGUZhJcsjj0qwlWhURZenblbIsPQh23ib9ViaYqzkI8PtGXhpjKVXYrIHARBlQIeMh01YHT6K00iajA/640?wx_fmt=png" data-index="15" style="width: 677px !important; height: 886.68px !important;"><span class="weui-primary-loading"><span class=""></span></span></span></p><p>Cloudera DataFlow 还提供对流的 NiFi 画布的直接访问,以便您可以在必要时检查执行的详细信息或解决问题。GUI 中的所有功能也可以通过 CDP CLI 或 CDF API 以编程方式使用。创建和管理流程的过程可以完全自动化并与 CD/CI 管道集成。</p><section data-mpa-template="t" mpa-from-tpl="t"><h2 mpa-is-content="t" style="margin: 5px;padding-right: 10px;padding-left: 10px;font-weight: bold;max-width: 100%;font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-variant-numeric: normal;font-variant-east-asian: normal;letter-spacing: 0.544px;text-align: justify;white-space: normal;widows: 1;border-left: 5px solid rgb(2, 30, 170);line-height: 32px;background-color: rgb(255, 255, 255);border-top-color: rgb(2, 30, 170);border-bottom-color: rgb(2, 30, 170);border-right-color: rgb(2, 30, 170);box-sizing: border-box !important;overflow-wrap: break-word !important;"><span style="color:#888888;border-color: rgb(2, 30, 170);"><span style="color: rgb(2, 30, 170);border-color: rgb(2, 30, 170);" mpa-is-content="t">结论</span></span></h2></section><p><span style="font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;">在生成数据时收集数据并在分析平台上快速提供数据,这对于任何需要实时处理数据流的项目的成功都是至关重要的。在本博客中,我们展示了 Cloudera DataFlow 如何让在云中创建、测试和部署数据管道变得容易。</span></p><p>Apache NiFi 的图形用户界面和丰富的处理器允许用户创建简单和复杂的数据流,而无需编写代码。交互式体验使得在开发过程中测试流程和排除故障变得非常容易。</p><p>Cloudera DataFlow 的流运行时增加了在云原生和弹性环境中执行生产流的稳健性和效率,使其能够扩展和缩小以适应工作负载需求。</p><p>在本博客的第二部分中,我们将了解如何使用 Cloudera 流处理 (CSP) 来完成我们的欺诈检测用例的实施,对我们刚刚摄取的数据执行实时流分析。</p><p>了解有关 Cloudera DataFlow 的更多信息并试一试的最快方法是什么?首先,访问我们新的Cloudera DataFlow 主页。然后,参加我们的互动产品之旅或注册免费试用。 </p><p>原文作者:André Araújo</p><p>原文链接:https://blog.cloudera.com/fraud-detection-with-cloudera-stream-processing-part-1/</p><p style="display: none;"><mp-style-type data-value="3"></mp-style-type></p><blockquote><p>本文使用 <a href="https://www.jianshu.com/p/5709df6fb58d" class="internal">文章同步助手</a> 同步</p></blockquote>

    相关文章

      网友评论

          本文标题:使用 Cloudera 流处理进行欺诈检测-Part 1

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