<commit_before># Learning Apache Storm

```bash
mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dpackaging=jar -Dversion=1.7 -Dfile=tools.jar -DgeneratePom=true

mvn compile exec:java -Dstorm.topology=com.pic.ala.learn.TestTopology.TestTridentTopology
mvn compile exec:java -Dstorm.topology=com.pic.ala.learn.TestTopology.TridentWordCount
mvn compile exec:java -Dstorm.topology=com.pic.ala.learn.TestTopology.TridentKafkaWordCount

storm jar target/TestTopology-0.0.1-SNAPSHOT.jar com.pic.ala.learn.TestTopology.TridentKafkaWordCount hdp01.localdomain:2181 hdp02.localdomain:6667
```

https://azure.microsoft.com/zh-tw/documentation/articles/hdinsight-storm-sensor-data-analysis/

## HOW TO USE:

```bash
# 1. DELETE the old topic & indexes:
/usr/hdp/current/kafka-broker/bin/kafka-topics.sh --zookeeper hdp01.localdomain:2181 --delete --topic ap_logs_test_222

curl -XDELETE 'localhost:9200/aplog_aes3g?pretty'
curl -XDELETE 'localhost:9200/aplog_pos?pretty'
curl -XDELETE 'localhost:9200/aplog_upcc?pretty'
curl -XDELETE 'localhost:9200/aplog_wds?pretty'

# 2. RECREATE the topic & indexes:
/usr/hdp/current/kafka-broker/bin/kafka-topics.sh --create --zookeeper hdp01.localdomain:2181 --replication-factor 1 --partition 1 --topic ap_logs_test_222

curl -XPUT 'localhost:9200/aplog_aes3g?pretty'
curl -XPUT 'localhost:9200/aplog_pos?pretty'
curl -XPUT 'localhost:9200/aplog_upcc?pretty'
curl -XPUT 'localhost:9200/aplog_wds?pretty'

# 3. START monitoring the topic:
/usr/hdp/current/kafka-broker/bin/kafka-console-consumer.sh --zookeeper hdp01.localdomain:2181 --topic ap_logs_test_222 --from-beginning

# 4. COMPILE & PACKAGE Storm topologies:
cd /root/workspace/LearnStorm/
mvn clean package

# 5. SUBMIT Storm topology: ApLogAnalyzer
storm jar target/LearnStorm-0.0.1-SNAPSHOT.jar com.pic.ala.ApLogAnalyzer

# 6. SUBMIT Storm topology: ApLogGenerator
storm jar target/LearnStorm-0.0.1-SNAPSHOT.jar com.pic.ala.ApLogGenerator

# 7. MODIFY Elasticsearch Mappings:

curl -XPUT 'http://localhost:9200/aplog_*/_mapping/*' -d  '{
      "properties" : {
        "apName" : {
          "type" : "string",
          "index": "not_analyzed" 
        },
        "functionID" : {
          "type" : "string",
          "index": "not_analyzed" 
        },
        "logType" : {
          "type" : "string",
          "index": "not_analyzed" 
        },
        "messageLevel" : {
          "type" : "string",
          "index": "not_analyzed" 
        },
        "systemID" : {
          "type" : "string",
          "index": "not_analyzed" 
        }
      }
}'
```<commit_msg>Updated.<commit_after># Learning Apache Storm

```bash
mvn install:install-file -DgroupId=jdk.tools -DartifactId=jdk.tools -Dpackaging=jar -Dversion=1.7 -Dfile=tools.jar -DgeneratePom=true

mvn compile exec:java -Dstorm.topology=com.pic.ala.learn.TestTopology.TestTridentTopology
mvn compile exec:java -Dstorm.topology=com.pic.ala.learn.TestTopology.TridentWordCount
mvn compile exec:java -Dstorm.topology=com.pic.ala.learn.TestTopology.TridentKafkaWordCount

storm jar target/TestTopology-0.0.1-SNAPSHOT.jar com.pic.ala.learn.TestTopology.TridentKafkaWordCount hdp01.localdomain:2181 hdp02.localdomain:6667
```

https://azure.microsoft.com/zh-tw/documentation/articles/hdinsight-storm-sensor-data-analysis/

## HOW TO USE:

```bash
# 1. DELETE the old topic & indexes:
/usr/hdp/current/kafka-broker/bin/kafka-topics.sh --zookeeper hdp01.localdomain:2181 --delete --topic ap_logs_test_222

curl -XDELETE 'localhost:9200/aplog_aes3g?pretty'
curl -XDELETE 'localhost:9200/aplog_pos?pretty'
curl -XDELETE 'localhost:9200/aplog_upcc?pretty'
curl -XDELETE 'localhost:9200/aplog_wds?pretty'

# 2. RECREATE the topic & indexes:
/usr/hdp/current/kafka-broker/bin/kafka-topics.sh --create --zookeeper hdp01.localdomain:2181 --replication-factor 1 --partition 1 --topic ap_logs_test_222

curl -XPUT 'localhost:9200/aplog_aes3g?pretty'
curl -XPUT 'localhost:9200/aplog_pos?pretty'
curl -XPUT 'localhost:9200/aplog_upcc?pretty'
curl -XPUT 'localhost:9200/aplog_wds?pretty'

# 3. START monitoring the topic:
/usr/hdp/current/kafka-broker/bin/kafka-console-consumer.sh --zookeeper hdp01.localdomain:2181 --topic ap_logs_test_222 --from-beginning

# 4. COMPILE & PACKAGE Storm topologies:
cd /root/workspace/LearnStorm/
mvn clean package

# 5. SUBMIT Storm topology: ApLogAnalyzer
storm jar target/LearnStorm-0.0.1-SNAPSHOT.jar com.pic.ala.ApLogAnalyzer

# 6. SUBMIT Storm topology: ApLogGenerator
storm jar target/LearnStorm-0.0.1-SNAPSHOT.jar com.pic.ala.ApLogGenerator

# 7. MODIFY Elasticsearch Mappings:

curl -XPUT 'http://localhost:9200/aplog_*/_mapping/*' -d  '{
      "properties" : {
        "apName" : {
          "type" : "string",
          "index": "not_analyzed" 
        },
        "functionID" : {
          "type" : "string",
          "index": "not_analyzed" 
        },
        "logType" : {
          "type" : "string",
          "index": "not_analyzed" 
        },
        "messageLevel" : {
          "type" : "string",
          "index": "not_analyzed" 
        },
        "systemID" : {
          "type" : "string",
          "index": "not_analyzed" 
        }
      }
}'
```

# 8. MONITOR the logs with Kibana
{'fraction_non_alphanumeric': 0.13570057581573897, 'fraction_numerical': 0.03742802303262956, 'mean_word_length': 3.4806534823731727, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '841673', 'n_tokens_mistral': 2078, 'n_tokens_neox': 1916, 'n_words': 326}