|
| 1 | +--- |
| 2 | +title: Use selective logging with a script action in Azure HDInsight clusters |
| 3 | +description: Learn how to use the selective logging feature with a script action to monitor logs. |
| 4 | +ms.service: azure-hdinsight |
| 5 | +ms.topic: how-to |
| 6 | +ms.custom: references-regions |
| 7 | +ms.date: 09/13/2023 |
| 8 | +--- |
| 9 | + |
| 10 | +# Use selective logging with a script action in Azure HDInsight |
| 11 | + |
| 12 | +[Azure Monitor Logs](../azure-monitor/logs/log-query-overview.md) is an Azure Monitor service that monitors your cloud and on-premises environments. The monitoring helps maintain their availability and performance. |
| 13 | + |
| 14 | +Azure Monitor Logs collects data generated by resources in your cloud, resources in on-premises environments, and other monitoring tools. It uses the data to provide analysis across multiple sources. To get the analysis, you enable the selective logging feature by using a script action for HDInsight in the Azure portal. |
| 15 | + |
| 16 | +## About selective logging |
| 17 | + |
| 18 | +Selective logging is a part of the overall monitoring system in Azure. After you connect your cluster to a Log Analytics workspace and enable selective logging, you can see logs and metrics like HDInsight security logs, Yarn Resource Manager, and system metrics. You can monitor workloads and see how they're affecting cluster stability. |
| 19 | + |
| 20 | +Selective logging allows you to enable or disable all the tables, or enable selected tables, in the Log Analytics workspace. You can adjust the source type for each table. |
| 21 | + |
| 22 | +> [!NOTE] |
| 23 | +> If Log Analytics is reinstalled in a cluster, you'll have to disable all the tables and log types again. Reinstallation resets all the configuration files to their original state. |
| 24 | +
|
| 25 | +## Considerations for script actions |
| 26 | + |
| 27 | +* The monitoring system uses the Metadata Server Daemon (a monitoring agent) and Fluentd for collecting logs by using a unified logging layer. |
| 28 | +* Selective logging uses a script action to disable or enable tables and their log types. Because selective logging doesn't open any new ports or change any existing security settings, there are no security changes. |
| 29 | +* The script action runs in parallel on all specified nodes and changes the configuration files for disabling or enabling tables and their log types. |
| 30 | + |
| 31 | +## Prerequisites |
| 32 | + |
| 33 | +* A Log Analytics workspace. You can think of this workspace as a unique Azure Monitor Logs environment with its own data repository, data sources, and solutions. For instructions, see [Create a Log Analytics workspace](../azure-monitor/vm/monitor-virtual-machine.md). |
| 34 | +* An Azure HDInsight cluster. Currently, you can use the selective logging feature with the following HDInsight cluster types: |
| 35 | + * Hadoop |
| 36 | + * HBase |
| 37 | + * Interactive Query |
| 38 | + * Spark |
| 39 | + |
| 40 | +For instructions on how to create an HDInsight cluster, see [Get started with Azure HDInsight](hadoop/apache-hadoop-linux-tutorial-get-started.md). |
| 41 | + |
| 42 | +## Enable or disable logs by using a script action for multiple tables and log types |
| 43 | + |
| 44 | +1. Go to **Script actions** in your cluster and select **Submit new** to start the process of creating a script action. |
| 45 | + |
| 46 | + :::image type="content" source="./media/hdinsight-hadoop-oms-selective-log-analytics-tutorial/select-submit-script-action.png" alt-text="Screenshot that shows the button for starting the process of creating a script action."::: |
| 47 | + |
| 48 | + The **Submit script action** pane appears. |
| 49 | + |
| 50 | + :::image type="content" source="./media/hdinsight-hadoop-oms-selective-log-analytics-tutorial/submit-script-action-window.png" alt-text="Screenshot that shows the pane for submitting a script action."::: |
| 51 | + |
| 52 | +1. For the script type, select **Custom**. |
| 53 | +1. Name the script. For example: **Disable two tables and two sources**. |
| 54 | +1. The Bash script URI must be a link to [selectiveLoggingScript.sh](https://hdiconfigactions.blob.core.windows.net/log-analytics-patch/selectiveLoggingScripts/selectiveLoggingScript.sh). |
| 55 | +1. Select all the node types that apply for the cluster. The options are head node, worker node, and ZooKeeper node. |
| 56 | +1. Define the parameters. For example: |
| 57 | + - Spark: `spark HDInsightSparkLogs:SparkExecutorLog --disable` |
| 58 | + - Interactive Query: `interactivehive HDInsightSparkLogs:SparkExecutorLog --enable` |
| 59 | + - Hadoop: `hadoop HDInsightSparkLogs:SparkExecutorLog --disable` |
| 60 | + - HBase: `hbase HDInsightSparkLogs: HDInsightHBaseLogs --enable` |
| 61 | + |
| 62 | + For more information, see the [Parameter syntax](#parameter-syntax) section. |
| 63 | + |
| 64 | +1. Select **Create**. |
| 65 | +1. After a few minutes, a green check mark appears next to your script action history. It means the script has successfully run. |
| 66 | + |
| 67 | + :::image type="content" source="./media/hdinsight-hadoop-oms-selective-log-analytics-tutorial/enable-table-and-log-types.png" alt-text="Screenshot that shows a successful run of a script to enable tables and log types."::: |
| 68 | + |
| 69 | +You'll see your changes in the Log Analytics workspace. |
| 70 | + |
| 71 | +## Troubleshooting |
| 72 | + |
| 73 | +### No changes appear in the Log Analytics workspace |
| 74 | + |
| 75 | +If you submit your script action but there are no changes in the Log Analytics workspace: |
| 76 | + |
| 77 | +1. Under **Dashboards**, select **Ambari home** to check the debug information. |
| 78 | + |
| 79 | + :::image type="content" source="./media/hdinsight-hadoop-oms-selective-log-analytics-tutorial/select-dashboard-ambari-home.png" alt-text="Screenshot that shows the location of the Ambari home dashboard."::: |
| 80 | + |
| 81 | +1. Select the **Settings** button. |
| 82 | + |
| 83 | + :::image type="content" source="./media/hdinsight-hadoop-oms-selective-log-analytics-tutorial/ambari-dash-board.png" alt-text="Screenshot that shows the Settings button."::: |
| 84 | + |
| 85 | +1. Select your latest script run at the top of the list of background operations. |
| 86 | + |
| 87 | + :::image type="content" source="./media/hdinsight-hadoop-oms-selective-log-analytics-tutorial/background-operations.png" alt-text="Screenshot that shows background operations."::: |
| 88 | + |
| 89 | +1. Verify the script run status in all the nodes individually. |
| 90 | + |
| 91 | + :::image type="content" source="./media/hdinsight-hadoop-oms-selective-log-analytics-tutorial/background-operations-all.png" alt-text="Screenshot that shows the script run status for hosts."::: |
| 92 | + |
| 93 | +1. Check that the parameter syntax from the parameter syntax section is correct. |
| 94 | +1. Check that the Log Analytics workspace is connected to the cluster and that Log Analytics monitoring is turned on. |
| 95 | +1. Check that you selected the **Persist this script action to rerun when new nodes are added to the cluster** checkbox for the script action that you ran. |
| 96 | + |
| 97 | + :::image type="content" source="./media/hdinsight-hadoop-oms-selective-log-analytics-tutorial/script-action-persists.png" alt-text="Screenshot that shows the checkbox for persisting a script action."::: |
| 98 | + |
| 99 | +1. See if a new node has been added to the cluster recently. |
| 100 | + |
| 101 | + > [!NOTE] |
| 102 | + > For the script to run in the latest cluster, the script must persist. |
| 103 | + |
| 104 | +1. Make sure that you selected all the node types that you wanted for the script action. |
| 105 | + |
| 106 | + :::image type="content" source="./media/hdinsight-hadoop-oms-selective-log-analytics-tutorial/select-node-types.png" alt-text="Screenshot that shows selected node types."::: |
| 107 | + |
| 108 | +### The script action failed |
| 109 | + |
| 110 | +If the script action shows a failure status in the script action history: |
| 111 | + |
| 112 | +1. Check that the parameter syntax from the parameter syntax section is correct. |
| 113 | +1. Check that the script link is correct. It should be: `https://hdiconfigactions.blob.core.windows.net/log-analytics-patch/selectiveLoggingScripts/selectiveLoggingScript.sh`. |
| 114 | + |
| 115 | +## Table names |
| 116 | + |
| 117 | +For a complete listing of table names for different log types (sources), see [Azure Monitor Logs tables](monitor-hdinsight-reference.md#azure-monitor-logs-tables). |
| 118 | + |
| 119 | +## Parameter syntax |
| 120 | + |
| 121 | +Parameters define the cluster type, table names, source names, and action. |
| 122 | + |
| 123 | +:::image type="content" source="./media/hdinsight-hadoop-oms-selective-log-analytics-tutorial/parameter-syntax-box.png" alt-text="Screenshot that shows the parameter syntax box."::: |
| 124 | + |
| 125 | +A parameter contains three parts: |
| 126 | +- Cluster type |
| 127 | +- Tables and log types |
| 128 | +- Action (either `--disable` or `--enable`) |
| 129 | + |
| 130 | +### Syntax for multiple tables |
| 131 | + |
| 132 | +When you have multiple tables, they're separated with a comma. For example: |
| 133 | + |
| 134 | +`spark HDInsightSecurityLogs, HDInsightAmbariSystemMetrics --disable` |
| 135 | + |
| 136 | +`hbase HDInsightSecurityLogs, HDInsightAmbariSystemMetrics --enable` |
| 137 | + |
| 138 | +### Syntax for multiple source types or log types |
| 139 | + |
| 140 | +When you have multiple source types or log types, they're separated with a space. |
| 141 | + |
| 142 | +To disable a source, write the table name that contains the log types, followed by a colon and then the real log type name: |
| 143 | + |
| 144 | +`TableName : LogTypeName` |
| 145 | + |
| 146 | +For example, assume that `spark HDInsightSecurityLogs` is a table that has two log types: `AmbariAuditLog` and `AuthLog`. To disable both the log types, the correct syntax would be: |
| 147 | + |
| 148 | +`spark HDInsightSecurityLogs: AmbariAuditLog AuthLog --disable` |
| 149 | + |
| 150 | +### Syntax for multiple tables and source types |
| 151 | + |
| 152 | +If you need to disable two tables and two source types, use the following syntax: |
| 153 | + |
| 154 | +- Spark: `InteractiveHiveMetastoreLog` log type in the `HDInsightHiveAndLLAPLogs` table |
| 155 | +- Hbase: `InteractiveHiveHSILog` log type in the `HDInsightHiveAndLLAPLogs` table |
| 156 | +- Hadoop: `HDInsightHiveAndLLAPMetrics` table |
| 157 | +- Hadoop: `HDInsightHiveTezAppStats` table |
| 158 | + |
| 159 | +Separate the tables with a comma. Denote sources by using a colon after the table name in which they reside. |
| 160 | + |
| 161 | +The correct parameter syntax for these cases would be: |
| 162 | + |
| 163 | +``` |
| 164 | +interactivehive HDInsightHiveAndLLAPLogs: InteractiveHiveMetastoreLog, HDInsightHiveAndLLAPMetrics, HDInsightHiveTezAppStats, HDInsightHiveAndLLAPLogs: InteractiveHiveHSILog --enable |
| 165 | +``` |
| 166 | + |
| 167 | +## Next steps |
| 168 | + |
| 169 | +* [Query Azure Monitor Logs to monitor HDInsight clusters](hdinsight-hadoop-oms-log-analytics-use-queries.md) |
| 170 | +* [Monitor cluster availability with Apache Ambari and Azure Monitor Logs](./hdinsight-cluster-availability.md) |
0 commit comments